hi,
Yes it is a valid Ctor. This is called the initialization list, here both the variables are getting initialized "var1(a1), var2(b1)". Its more optimized and faster than assigning the values in Ctor as given below.
class myClass
{
int var1,var2;
public:
myClass(int a1, int b1)
{
var1 =a1;
var2 =b1;
}
};
Also this is the only way to assign values to the constant class variables in c++. As the constant variables has to be initialized with the value (and must not be assigned) while defining it and C++ don't allow to initialize vars inside class definition.