473,385 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2949
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.