Accessing classes-different ways
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!
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...
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...
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 theIt is workable, but clunky - the C and m_C prefixes are unnecessary. Prefer something simple, like this:
CSomething m_CSomething;
most standard way?
class Something // class{};Something something; // instance
Quote:Original post by JaqenUsually 'member', when used for instance variables - occasionally 'my'.
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...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement