|
-
July 16th, 2009, 10:45 AM
#1
[RESOLVED] Enum in template class
Can anyone help with the cause and resolution to this compile error?
Here is the code:
Code:
template <typename T>
class BigQueue {
public:
enum QueueState {GOOD, BAD, UNKNOWN};
....
private:
QueueState getQueueState();
....
};
template <typename T>
QueueState BigQueue<T>::getQueueState()
{
return m_queueState;
}
This is not the complete code. I tried to pull out only the parts that pretain to the compile error. Also, all of this is in the .h file. Using gcc on Linux. If more information is needed please let me know.
Here is the compile error:
error: expected constructor, destructor, or type conversion before "BigQueue"
I read about undeducible context having to do with this compile error but I really did not understand exactly what that means and how to fix it. Something to do with returning the enum type from a function that is part of the template class.
Will someone please help with what is going on?
Thanks.
Last edited by Yadrif; July 16th, 2009 at 10:53 AM.
-
July 16th, 2009, 11:18 AM
#2
Re: Enum in template class
QueueState is defined within the BigQueue class template, so you cannot use it as a return type when that context cannot be deduced with qualification. As such, you should write:
Code:
template <typename T>
typename BigQueue<T>::QueueState BigQueue<T>::getQueueState()
{
return m_queueState;
}
I assume that the declaration of m_queueState was replaced by "....".
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|