I came across this code, and realized that I can not recall the type of initialization used, nor its supposed behavior. Point p=(3,2);
only seems to pass the latter value (2 in this case) as an argument to the constructor, so that the PrintOut shows something like x=2 y=5
as opposed to the expected x=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);
}
Aucun commentaire:
Enregistrer un commentaire