Hi all!
I'm writing a program in which I define a class named Point. the objects of the class are points of 2 numerical coordinates(x and y). I wanna write a constructor for my class with the following signature:
Point(int x,int y)
should I write anything in the body of my constructor or should I leave it empty?
I mean sth like this:
is it ok to do so?Code:class Point { public: int x,y; Point(int x,int y) { Point::x=x; Point::y=y; } };
I wanna tell the constructor to set the x and y attributes of the objects as written in the parenthesis that come after them. if I leave it's body empty, does it know to do such a thing?



LinkBack URL
About LinkBacks


