Jump to content
  • Advertisement

Archived

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

paneb

class in other class

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

is it alright to have a pointer to another class as a member of another class? in code:
class CLASS1   {
...
};

class CLASS2   {
private:
 CLASS1 pt;
...
};
 
and then in the constructor i would allocate memory for pt..is that alright? i am asking because i dont want to be doing something absurd.. thanks [blocks are apparently case sensitive] [edited by - Magmai Kai Holmlor on April 18, 2003 12:33:44 AM]

Share this post


Link to post
Share on other sites
Advertisement
Yeah, having pointer is fine, though you might want to consider using a smart pointer. It''s just easier iff you use the right type of smart pointer, the ones in boost are probably the easiest to use.

However, naming classes in ALLCAPS is bad style (it''s legal code though). Traditionally, ALLCAPS is reserved for MACROS_ONLY.

- Magmai Kai Holmlor

"Nobody will listen to a stone no matter how hard you throw it."

[Look for information | GDNet Start Here | GDNet Search Tool | GDNet FAQ | MSDN RTF[L] | SGI STL Docs | STFW | Asking Smart Questions ]

[Free C++ Libraries | Boost | ACE | Loki | MTL | Blitz++ | wxWindows| Spirit(xBNF)]
[Free C Libraries | zlib ]

Share this post


Link to post
Share on other sites
alright, thanks..i''ll follow your advice for the naming..its just i dont like the CName way of doing it

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!