Archived

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

flamewill

Pointer to data member?

Recommended Posts

flamewill    122
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
Zipster    2359
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
flamewill    122
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