08 Jul, 2007, Davion wrote in the 1st comment:
Votes: 0
I'm switching servers and this problem popped up. It's a bunch of functors I wrote to work with for_each that generate queries for MySQL. Seems my knowledge of inheritance, or atleast, inheritance when involving templates has deminished and I cannot figure this out. Why is it outputting those errors? All code in pastebin here! http://www.mudbytes.net/index.php?a=past...
09 Jul, 2007, Guest wrote in the 2nd comment:
Votes: 0
I don't know the first thing about inheritance, so this is a complete shot in the dark.

Is the order of the templates the same in your header file as it is in the Pastebin? And does your save.c file include the header file those are from?
09 Jul, 2007, Davion wrote in the 3rd comment:
Votes: 0
Those are in save.c. The only apperance of any of these classes is actually in save.c, in that order.
09 Jul, 2007, Justice wrote in the 4th comment:
Votes: 0
Well, the code looks good to me, but the errors make me think it's not finding the parent type. Are those all of the errors you're getting?
09 Jul, 2007, Dorian wrote in the 5th comment:
Votes: 0
Davion said:
I'm switching servers and this problem popped up. It's a bunch of functors I wrote to work with for_each that generate queries for MySQL. Seems my knowledge of inheritance, or atleast, inheritance when involving templates has deminished and I cannot figure this out. Why is it outputting those errors? All code in pastebin here! http://www.mudbytes.net/index.php?a=past...


Short answer:

Put a "this->" in front of every member variable and function from the base class.

Long answer:

C++ lookup rules are a little funky within subclasses which inherit template classes. When you use a template parameter in your inheritance part, all the stuff you inherit from the base class is dependent on the template parameter used. Normally, C++ only performs a non-dependent name lookup, so it only looks for variables that have no dependency upon a template parameter. In your situation, you need to tell the compiler that it needs to lookup the dependent names as well as the non-dependent ones. There are couple of ways of doing this, but the easier for you is putting a this-> in front of everything inherited that you use in the subclass.
09 Jul, 2007, Davion wrote in the 6th comment:
Votes: 0
Thanks, works.

Just for future reference, what are the other ways of getting it to work?
09 Jul, 2007, Dorian wrote in the 7th comment:
Votes: 0
Davion said:
Just for future reference, what are the other ways of getting it to work?


This is a bit off the top of my head, so it may need to be tweaked a bit. The first form that comes to mind is:

TemplateBaseClassName<T>::base_class_member

Where T is the template parameter you passed to the base class. Alternatively, you could implant references in your subclass that reference the base class members. While this wouldn't work for functions, this would only need you to initialize the references within the constructor once. Those are the best solutions which I can come up with right now.
0.0/7