This is a basic C++ question, not OOP. When ever you create a class the compiler automatically creates a default constructor and a copy constructor. The default constructor is required if you want to create objects like this:CFoo foo;
As soon as you create ANY constructor, the compiler requires you to write ALL constructors. In other words, it no longer creates the default constructor for you. That means if you write:struct Point { int x; int y; }; Point origin; // legal - using compiler-supplied default constructor
...but if you write this...struct Point { int x; int y; Point(int x, int y): x(x), y(y) {} };
...the compiler no longer generates the default constructor...Point origin; // illegal! no default constructor Point origin (12,45); // legal - using Point(int,int)
Note that a default constructor does not have to take 0 arguments, you simply must be able to call it with 0 arguments. Like this...struct Point { int x; int y; Point(int x=0, int y=0): x(x), y(y) {} // default parameters };
Now everything's happy again...Point origin; // legal - using Point(int,int) Point origin (12,45); // legal - using Point(int,int)
Hope this clarifies more than it confuses! Cheers, Eric