Aug 25, 2014 at 8:27am
I have this line of my code .. vector <Team *> teams(4);
visual C++ compiler says "expected type specifier" when i hover the cursor over 4 in teams(4)
.
If if i change the line to
vector <Team *> teams(a typename like int,double,etc)
there is no longer any error.
But i want to create the Team *
vector with 4 elements and i dont think im doing anything wrong.
Any suggestions?
Aug 25, 2014 at 8:59am
I don't know why you get an error. Maybe it would be easier to say what's wrong if you posted real code.
Aug 25, 2014 at 9:24am
You can't specify the constructor in the class body like that.
Just leave out the constructor in the class body
and specify the constructor in the constructor initialization list.
1 2 3 4
|
Group::Group(char &)
: teams(4)
{
...
|
In C++11 (or later) you
can do it in the class body if you want, by using curly brackets instead of normal parentheses.
|
vector <Team *> teams{4};
|
Last edited on Aug 25, 2014 at 9:24am