Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

JoeDark

Quick generic class q

This topic is 6385 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The only reason I ask this question is that my reference book doesn't make mention of it. Can you only declare a generic class with a base class? i.e.
  
// --------------------------------------------------------------

template <class CType> class gen_class{};

class base {};

class derived : public base {};

int main()
{
   gen_class<derived> d_class;
}

// -------------------------------------------------------------

  
When I try to do this the compiler(DJGPP) says: type 'derived' is not a base type for type 'base' Sounds to me like you can only use base classes.. Why must they make things so difficult? JoeDark Edited by - JoeDark on January 25, 2001 1:56:53 PM Edited by - JoeDark on January 25, 2001 1:58:30 PM

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Works for me using VC6...

-Mike

Share this post


Link to post
Share on other sites
Ok, I looked at it a bit closer, and it doesn't seem to complain about the actual declaration, it seems to give me that error regarding the member functions of the generic class.

Hmm.. I see what it's saying now. Thanks for you help.. turns out I was trying to put a base class into a derived pointer. Don't I feel stupid In that context the error makes perfect sense.

JoeDark

Edited by - JoeDark on January 26, 2001 2:13:33 PM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!