Possible Duplicate:
Initializing in constructors, best practice?
Advantages of using initializer list?
I have the following two ways to define the constructor in the Point Class :
class Point
{
public :
Point(double X,double Y):x(X),y(Y){}
Private :
double x,y;
}
Another way :
class Point
{
public :
Point(double X,double Y)
{
x= X;
y = Y;
}
Private :
double x,y;
}
I want to know which one is better and why?Is there is the use of copy ctor in the first case? Where each one is preferred?Can some explain with the example? Rgds, Softy