473,466 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Chinese student seek help


I'm a Chinese student
I found a very confusable proble
when I studied Visual C++ 6.0
The problem is

#include <iostream.h

class confusable
private
int x,y

public
confusable(int x1,int y1)
x=x1; y=x1
cout<<"In construct !\n"
confusable(confusable & obj)
*this=obj
cout<<"In copy construct !\n"
// 下面的析构函数 有与没有 令人奇怪 !!
//very confusable below
//~confusable( ){ cout<<"deconstruct ... \n";
}

void main(
{ // 为了便于观察,故意将对象数组设置 局部变
confusable confuse[2]={ confusable(1,1),confusable(2,2) }

/
1. If I don't define ~confusable( ),the resul
is below

In construct
In copy construct
In construct
In copy construct

2.If I define ~confusable( ),the resul
is below

In construct
In construct
deconstruct ..
deconstruct ..

question
Where is the "In copy construct !"
In my opinion
The result should be

In construct
In copy construct
In construct
In copy construct
deconstruct ..
deconstruct ...

Please tell me why
The reason please!
Easily and clearly

*/
Nov 16 '05 #1
1 2951
Hi,

I'm a Chinese student.
I found a very confusable problem
when I studied Visual C++ 6.0.
The problem is:

#include <iostream.h>

class confusable {
private:
int x,y;

public:
confusable(int x1,int y1){
x=x1; y=x1;
cout<<"In construct !\n";
}

confusable(confusable & obj){
*this=obj;
cout<<"In copy construct !\n";
}

// 下面的析构函数 有与没有 令人奇怪 !!!
//very confusable below:
//~confusable( ){ cout<<"deconstruct ... \n"; }
};
void main( )
{

{ // 为了便于观察,故意将对象数组设置 局部变量
confusable confuse[2]={ confusable(1,1),confusable(2,2) };
}

}

/*
1. If I don't define ~confusable( ),the result
is below:

In construct !
In copy construct !
In construct !
In copy construct !
2.If I define ~confusable( ),the result
is below:

In construct !
In construct !
deconstruct ...
deconstruct ...

question:
Where is the "In copy construct !"?
In my opinion,
The result should be:
"
In construct !
In copy construct !
In construct !
In copy construct !
deconstruct ...
deconstruct ..."

Please tell me why!
The reason please!!
Easily and clearly!

*/


This question You should ask in VC++ or C++ group.

As i see your copy constructor copies reference... that
isn't a good practise. As i remember from my C++ coding
in copy constructor i was copying only object fields.

First constructor code looks that it isn't do what it
should... but it doesn't matter for your output.

Regards

Marcin

PS: Try to set more descriptive mail's subject for a next time :)

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kobi Lurie | last post by:
Hello all, I'm trying to make a simple script beginner level script, with just functions. it uses the functions: file_get_contents substr taking into an array the text substr took then...
3
by: Coco | last post by:
Hi! I managed to display chinese character in my web form (.aspx), in certain situation i need to to set the text of the label of my web form in chinese character programatically which is done in...
6
by: Zhang Weiwu | last post by:
Hello. I am working with a php software project, in it (www.egroupware.org) Chinese simplified locate is "zh" while Traditional Chinese "tw". I wish to send correct language attribute in http...
1
by: Waitman Gobble | last post by:
Hello, I am new to Python. I am having trouble with zipfile.py. On a Linux machine with python 2.4.2 I have trouble opening a zipfile. Python is complaining about the bit where it does a...
1
by: Chinese student(Adam Zhang) | last post by:
I'm a Chinese student I found a very confusable proble when I studied Visual C++ 6.0 The problem is #include <iostream.h class confusable private int x,y
8
by: pabv | last post by:
Hello all, I am having a few issues with encoding to chinese characters and perhaps someone might be able to assist. At the moment I am only able to see chinese characters when displayed as...
1
by: CYF | last post by:
My Computer : Window XP Pro English Version -> I have set the "Regional" to "Taiwan" Mysql 4.1.x -- > set to big5 already i am using C# to program. When i retrieve chinese character from the...
7
by: c.verma | last post by:
I have a web application. There is a page which has a datagrid on it.The datagrid displays the data that comes from SAP. SAP sends the chinese characters to this grid. Before I display CHinese...
2
by: Wassy | last post by:
Hi, i have a website which contains both chinese and english content which is stored in a database. Each record in the dB has an english and Chinese field. If a user enters a search string i have...
4
by: dragon52 | last post by:
Hi there, I am writing php to send email containing Chinese text. The chinese displays correctly depending on different mail servers, it seems. I can read the chinese text if I open the email...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.