C++ Classes Proper Syntax

Hello, I am currently trying to learn classes in C++. I came across this piece of code today, but I am confused about its syntax. If you look at line 10, it says :asize(size) . What does this exactly mean? I don't think this is the right C++ classes syntax. Please help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  class Student
{
public:
	Student(int size);
	~Student();
private:
	int asize;
	int *array;
};
Student::Student(int size):asize(size)
{
	array = new int[size];
}
Student::~Student()
{
	delete [] array;
	cout << "free\n";
}
I don't think this is the right C++ classes syntax

its correct

:asize(size) this means that the value of size will be stored in asize
or its equivalent to asize = size;
Last edited on
Member initialization. C++ syntax.

http://www.informit.com/articles/article.aspx?p=1852519
Topic archived. No new replies allowed.