1

error: expected constructor, destructor, or type conversion before '<' token

Relevant section of C++ code:

InputParser::vector<bar*> getFooBar(){
return bars;
} 

We have defined vector bars; as a private variable in the header file.

Can someone please explain how to resolve this error?

2
  • 2
    where is the rest of the code? Commented Feb 21, 2011 at 23:06
  • What you think is relevant and what is actually relevant are often two very different things, especially in cases where you are here precisely because you do not understand the problem. This is one of those times. Commented Feb 21, 2011 at 23:08

2 Answers 2

7

Your question is not too clear. If this is supposed to be a std::vector, that's not the type you are using. Assuming getFooBar is a member of InputParser, the syntax is:

std::vector<bar*> InputParser::getFooBar()
{
    return bars;
} 
Sign up to request clarification or add additional context in comments.

2 Comments

No problem. I suggest getting a decent book and brushing up on the declaration and definition of class members. :)
@VJo: Thanks! I practise on IRC ;P
0

Maybe you want to wrtie this :

const std::vector<bar*>& InputParser::getFooBar()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.