I came across this code and realized that I could not remember the type of initialization used and its intended behavior.
Point p=(3,2);it seems to pass the last value (2 in this case) as an argument to the constructor, so PrintOut shows something like x=2 y=5unlike the expectedx=3 y=2
class Point{
public:
Point(int x=5,int y=5):a(x),b(y){};
void printOut()const{
cout<<"x= "<<a<<"y= "<<b<<endl;}
private:
int a,b;
};
void main(){
Point p=(3,2);
}
source
share