-
Constructor inheritence
My c++ is a bit rusty in the case of class related matters.
I'm wondering how / if constructors are inherited in derived classes. Take for example this class:
Code:
class Agent() {
Agent();
Agent(vector Location);
~Agent();
// other non important functions
};
class Worker : public Agent {
// class functions
};
Now can the base class constructor be used as the constructor for the derived class? IE
Worker *object = new Worker(position);
Can any one offer the specifics of this application? Is it legal, better way to do it, etc etc.
Thanks.
-
Worker in fact has a default constructor but the Agent constructor is called first. Yes, it is inherited.
-
What about the case of me wanting to use the overloaded function? Agent(sVector location) for the worker class?