flysnow
December 3rd, 2002, 02:01 AM
When ,which funcition will be called ? how about priority?
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!
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!