O
Ook
I'm having trouble comprehending what exactly "default construction" is. I
know how to provide a constructor with initial values, so that if I, for
example, in my code do this:
MyClass zoot(1,2);
It would instantiate MyClass, passing 1 and 2 to my constructor which in
turn would do whatever I want it to. Would a default constructor be as
follows:
MyClass zoot;
With no parameters passed? In my class declaration, would I do this:
class Zoot
{
Zoot(); // default constructor?
Zoot( int a, int b); // constructor with initial values.
....
}
Zoot::Zoot()
{
// default constructor, no parameters passed, do whatever you want?
}
Zoot::Zoot( int a, int b )
{
// constructor with initial values
}
Am I on the right track? IOW, a default constructor is simply a constructor
that receives no parameters, but you can still write code to do what you
want with it?
know how to provide a constructor with initial values, so that if I, for
example, in my code do this:
MyClass zoot(1,2);
It would instantiate MyClass, passing 1 and 2 to my constructor which in
turn would do whatever I want it to. Would a default constructor be as
follows:
MyClass zoot;
With no parameters passed? In my class declaration, would I do this:
class Zoot
{
Zoot(); // default constructor?
Zoot( int a, int b); // constructor with initial values.
....
}
Zoot::Zoot()
{
// default constructor, no parameters passed, do whatever you want?
}
Zoot::Zoot( int a, int b )
{
// constructor with initial values
}
Am I on the right track? IOW, a default constructor is simply a constructor
that receives no parameters, but you can still write code to do what you
want with it?