C++ Derived Class
My assignment is a Binary Search Tree derived from a Binary Tree, in my driver program this is how I've created a BST object. But I am slightly confused because I know there must be a constructor but no where in my assignment does it actually call for a construct开发者_如何学JAVAor for the derived class.
int main() {
int x = 0;
int n = 0;
int len = 0;
int total = 0;
int seed = 0;
bool y;
cin >> n;
vector<int> v;
binSTree<int> t;
I'm having a hard time using these "pre" and "code" tags, the vector is actually vector<int> v;
and the tree is really binSTree<int> t;
With less than and greater signs around the int of course.
the error in my program is as follows:
In file included from prog6.cc:2:
binSTree.h:1:9: error: macro names must be identifiers
prog6.cc: In function ‘int main()’:
prog6.cc:16: error: ‘binSTree’ was not declared in this scope
If the base class is default constructable, and the derived class does not make an explicit call to the base class constructor, the compiler inserts a call to the default base class constructor before calling the derived class constructor.
but that's got nothing to do with the error you are encountering, which is:
In file included from prog6.cc:2:
binSTree.h:1:9: error: macro names must be identifiers
Remember, always always look at the first error your compiler produces, not the one at the bottom. This means you have, someplace in binSTree.h
, on the first few lines, something like
#define ...
where the dots are something invalid.
精彩评论