Class constructor syntax question

Aug 3, 2011 at 1:22pm
Hi,

I had this constructor given to me.

1
2
3
4
5
6
7
8
9
// Screen's constructor
Screen::Screen(int_s height, int_s width, char bkground):
	_height(height),// initialises _height with height
	_width(width),  // initialises _width with width
	_cursor(TOP_LEFT),		// initialises _cursor to the starting position
	_screen(height * width, bkground)	// size of _screen is height * width
{ ...
some code 
... }


What's the : operator doing? And why not rather change the data members (_height,_width,_cursor) inside the {}?

Thanks :)
Last edited on Aug 3, 2011 at 1:23pm
Aug 3, 2011 at 1:24pm
Topic archived. No new replies allowed.