Jump to content
  • Advertisement
Sign in to follow this  
davidcoleman

Accessing classes-different ways

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

I have looked at some source code and noticed that class is interfaced different ways m_CSomething.SomeFunction(); m_CSomething->SomeFunction(); &CSomething::SomeFunction(); When do I use which version? Does it make difference if I use #include in my .h or .cpp file? How do I share single instance of a class between different classes, what do I need to include where? Considering naming convention, is the CSomething m_CSomething; most standard way? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Sorry I can't really help you because I've been curious about the same thing too.

But I'm curious as to what the m stands for in the naming conventions a lot of people seem to use (m_CSomething), if anyone could tell me...

Share this post


Link to post
Share on other sites
Quote:
Original post by davidcoleman
I have looked at some source code and noticed that class is interfaced different ways

m_CSomething.SomeFunction();
m_CSomething->SomeFunction();
&CSomething::SomeFunction();

When do I use which version?

something.func() calls a member function on an object instance named 'something'.
something->func() calls a member function on a pointer variable named 'something'.
Something::func() calls a static member of a class named 'Something'

Quote:
Does it make difference if I use #include in my .h or .cpp file?
If you need the included file in your header file, included it there, otherwise include it only in your source file to reduce dependencies.

Quote:
Considering naming convention, is the
CSomething m_CSomething;
most standard way?
It is workable, but clunky - the C and m_C prefixes are unnecessary. Prefer something simple, like this:
class Something // class
{
};

Something something; // instance




Quote:
Original post by Jaqen
But I'm curious as to what the m stands for in the naming conventions a lot of people seem to use (m_CSomething), if anyone could tell me...
Usually 'member', when used for instance variables - occasionally 'my'.

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!