1

I have a template class called Stack which I'm trying to inherit from. I do this:

template <class T> class Queue : public Stack
{ };

but the compiler says:

error: expected class-name before '{' token

What's wrong?

2
  • 3
    Please add Stack definition, and the line where the compiler shows the error Commented Oct 26, 2011 at 12:18
  • You should definitely work on your accept-rate to give others a motivation for answering your questions. If you don't know what I'm talking about, read the FAQ. Commented Oct 26, 2011 at 14:20

2 Answers 2

7

If Stack is a template, then you have to provide it's template arguments when you reference it.

Sign up to request clarification or add additional context in comments.

Comments

0

The error is possibly in your Stack class. The compiler has only tried to compile it now because it is being used.

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.