Skip to main content
gamedev.net
🔒 Locked

Template class help [c++]

Started by wolf_in_woe 1 reply 650+ views
Original Post
wolf_in_woe
wolf_in_woe
I have run into a problem in a class i have just written with templating. I've fixed this problem before, recently in fact but for some reason the solution i used has escaped my mind all evening... The set up: I have a templated class with a class embedded inside of it... The embedded class is not templated... The problem: Error: expected constructor, destructor, or type conversion before '*' token Location of problem: 1 - template 2 - t_class::e_class* t_class::e_class::DoSomething() 3 - { 4 - //Do something and return a pointer of type e_class 5 - } Using dev c++, clicking on the error msg, sends me to line 2 of this segment in 4 places of my code. If anyone knows what i need to do, let me know plz. Any help is appreciated, thx!
Fruny
Fruny
typename t_class::e_class*

Because it is a dependent name, without that keyword, your compiler assumes that t_class::e_class is a static member variable.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Zakwayda
Zakwayda
Try:
typename t_class<type>::e_class* t_class<type>::e_class::DoSomething()
(The reason for this has been covered in some recent threads...)

[Edit: Here you go. (Oops, just see Fruny's post.)]

Topic Locked

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

Sign in to reply to this topic.