I have a class named myGraph which is derived from graph
If I know the number of vertices when I call the constructor, I will be able to use the following constructor.
myGraph(int numOfV) : graph(numOfV)
{
// initialize...
}
I want to compute the number of vertices in the constructor and then inherit graph inside the constructor. How to do so?
myGraph(int a, int b)
{
/* using a,b to initialize...
a sequence of push operation on (vector<T>)verticeList */
int numOfV = this->verticeList.size();
// inherit...
myGraph(numOfV); // it will not work
}
Please note that
the procedure I use to compute the number of vertices is complicated.(many lines of code rather than
a+b)the number of vertices depends on the instance variables in
myGraph, so I need to initialize the members ofmyGraphfirst and then inherit the remaininggraphpart.