By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
 446,148 Members | 1,373 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,148 IT Pros & Developers. It's quick & easy.

# doubt not going on : operator

 P: 11 Hi I have the following code: Expand|Select|Wrap|Line Numbers struct Point {     double x, y;       inline Point(double X = 0, double Y = 0) : x(X), y(Y){ }        };   can anybody clue WHY after " ) " , the programmer has used  : and in braces { } no code is wriiten. does he mean to make abstract class . or abstract structure? Consequently he has taken this example carried forward to make segment class using Point studture where he makes use of   class Segment { public:     inline Segment(const Point &a, const Point &b) : pointA(a), pointB(b){ }            inline void setPointX(const Point &val) {pointA = val;}     inline void setPointY(const Point &val) {pointB = val;}   Private : Point pointA, point B }   May i seek anybody help please. Thanks and Regards, Mack. Mar 7 '07 #1
Share this Question
1 Reply

 Expert 100+ P: 1,510 the : x(X), y(Y) in Expand|Select|Wrap|Line Numbers struct Point {     double x, y;       inline Point(double X = 0, double Y = 0) : x(X), y(Y){ }        };   is an initialisation list to initialise the data member x and y, have a look at the tutorial http://www.cprogramming.com/tutorial/initialization-lists-c++.html in addition to other reasons it is more efficient than to use assignment, e.g. Expand|Select|Wrap|Line Numbers   inline Point(double X = 0, double Y = 0)         { x=X; y=Y; }          Mar 7 '07 #2

### Post your reply

Sign in to post your reply or Sign up for a free account.