Jump to content
  • Advertisement

Archived

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

flamewill

Pointer to data member?

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

According to ANSI C++, does a pointer to a data member need to be clarified by the namespace? For example:
class One
{
private:
  int _x;

public:
  int* getPx() { return &_x; }
};


class Two
{
private:
  int* _pY;

public:
  void setPy( int* pY ) { _pY = pY; }
};
Do I need to use One::int* instead of plain int* ? [edited by - flamewill on August 8, 2003 2:14:21 AM]

Share this post


Link to post
Share on other sites
Advertisement
You'd only need to clarify the namespace if it's a custom type created within a class, such as an enumeration or nested class. Of course this includes if it was created in another namespace, in which case you'd need it also.

[edited by - Zipster on August 8, 2003 2:23:50 AM]

Share this post


Link to post
Share on other sites
AFAIK (second post I''ve seen so far today with them) isn''t one underscore on variable names a big no-no by the standard?

Share this post


Link to post
Share on other sites
quote:
Original post by antareus
AFAIK (second post I''ve seen so far today with them) isn''t one underscore on variable names a big no-no by the standard?

It is? I''m just a beginner who saw some books do it and thought it is a neat idea. If there is any particular reason the standard discourages it, I''d like to know please.

Share this post


Link to post
Share on other sites
I forgot to mention, that also includes typedefs created within a class.

As for the naming, I believe it conflicts with something else. Not sure though.

Share this post


Link to post
Share on other sites
Identifiers beginning with leading underscores are reserved for the implementation. A standard header file could #define _x to mean anything it wants.

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!