Skip to main content
gamedev.net
🔒 Locked

c++ template double nesting

Started by elijah Jun 2, 2003 at 5:53 AM 4 replies 500+ views
Original Post
elijah
elijah
My question is how can I use a C++ template object that it's own template class is also defined as a template. I created two template classes:
 
template <class T>
class a
{....
};

template <class T>
class b
{....
};
and another class:
 
class c
{...
};
 
The following object definition is legal:
  
b<c> aObj;
But:
   
a<b> aObj;

Or:

a<b<c>> aObj;
is rejected by the compiler. Is there a way overcome this template's double nesting problem ? I would happy to know what you think. [edited by - elijah on June 2, 2003 6:59:12 AM] [edited by - elijah on June 2, 2003 7:02:48 AM] [edited by - elijah on June 2, 2003 7:04:50 AM]
sbennett
sbennett
Try
a<b<c> > aObj;

Note the space between the two >s. Without it, the compiler sees it as a >> bitshift operator, which is obviously illegal here.
elijah
elijah
quote:

Without it, the compiler sees it as a >> bitshift operator, which is obviously illegal here.




sbennett you are right, this was my problem, I didn''t have a space between the signs, this was the reason why the compiler rejected my code. Now it works,
thanks
elijah
elijah
quote:

or use typedefs



not a bad idea , thanks

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.