|
-
December 3rd, 2002, 03:01 AM
#1
A summary for constructor, copy constructor and assign operator by myself ,right or ?
When ,which funcition will be called ? how about priority?
Code:
eg:
class T
{
public :
T( int );
T();
};
T fun1()
{
T t1;
return t1;
}
void fun2(T t)
{
return ;
}
T t; //constructor
T t2 = t1 ; // copy constructor
T t2 = 1 ; // constructor
t2 = t1 ; // operator =
t2 = fun() ;// copy constructor and operator =
fun2( t1) ; //copy constructor
If you define operator = funciton to accept integer parameter,
t2 = 1 ; // call operator =
otherwise
t2 = 1 ; //call constructor first and the call default operator =.
Any thing need to add ? pls give your comments ,Thanks!
Last edited by flysnow; December 3rd, 2002 at 03:06 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|