473,506 Members | 16,951 Online
Bytes | Software Development & Data Engineering Community
+ 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 2958
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
3078
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
3195
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
22213
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
4205
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
291
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
11931
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
2849
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
4280
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
6268
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
6571
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
7218
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
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7307
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,...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5614
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,...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3188
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
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.