Jump to content
  • Advertisement
Sign in to follow this  
graveyard filla

errors putting a class inside another class's namespace

This topic is 4987 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

hi, im getting a strange error. i have 3 classes, Text_Box, Text_Box_For_Chat_Box, and Chat_Box. Text_Box_For* inherits from Text_Box.now, if i put Text_Box_For* inside of Chat_Box's namespace (not sure if thats the right term), i get errors. if i put it in the global namespace, i don't get error. the error are about un-declared identifier's wherever i use Text_Box_For*'s members that were inherited from Text_Box. if this doesnt make any sence, heres a code snippet. gives errors:
class Text_Box
{
   protected:
  
      int some_member;
};

class Chat_Box
{
    class Text_Box_For_Chat_Box : public Text_Box
   {
       my stuff here
   };

  my stuff here
}

void Text_Box_For_Chat_Box::SomeFunction()
{
 //UNDECLARED IDENTIFIER!!
  some_member = blah;
};

now, i don't get these errors if i do this:
class Text_Box
{
   protected:
  
      int some_member;
};

class Text_Box_For_Chat_Box : public Text_Box
{
    my stuff here
};

class Chat_Box
{
  my stuff here
}

void Text_Box_For_Chat_Box::SomeFunction()
{
  some_member = 1;
};

anyone have any ideas? thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
When you write this:

class Chat_Box
{
class Text_Box_For_Chat_Box : public Text_Box
{
};
};

you are creating nested class with full name Chat_Box::Text_Box_For_Chat_Box, so your function is called Chat_Box::Text_Box_For_Chat_Box::SomeFunction();

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!