Skip to main content
GameDev.net gamedev.net
🔒 Locked

nested class c++ template horror!!

Started by fiwl Apr 14, 2002 at 2:16 PM 1 replies 650+ views
Original Post
fiwl
fiwl
Hello, I'll get straight to it and describe my problem. I have a template class, which has, as one of its members, a second class (i.e. defined within the class). Now one of my member functions for the template class neeeds to return a pointer to the 'second class' type, like this: template <class MYDATA> SecondClass *FirstClass::Function(){...} (all that should be on one line) When i complile i get errors about 'expected ; after *'. What am I doing wrong? -- Thanks in advance.... Fiwl. [Edit: Type "&lt; for your opening angular brackets with includes and templates outside of source boxes.] [edited by - Oluseyi on April 14, 2002 4:54:13 PM]
Oluseyi
Oluseyi
template < class MYDATA > SecondClass * FirstClass< MYDATA >::Function() 

If SecondClass is defined within FirstClass, then it''s not globally visible and needs to be qualified:
template < class MYDATA >
FirstClass< MYDATA >::SecondClass * FirstClass< MYDATA >::Function()


[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
fiwl
fiwl
Thanks, thats solved my problem. Templates are tricky....

--
Fiwl

Topic Locked

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

Sign in to reply to this topic.