Does anyone now answer to this:

Suppose class X includes a data elements common declared as public. How can it be
accessed by all functions in the same name space ?

Recommended Answers

All 2 Replies

X::variablename if the variable is static or else (Instance of X).variablename.

Does anyone now answer to this:

Suppose class X includes a data elements common declared as public. How can it be
accessed by all functions in the same name space ?

The question is not much clear to me. I assume that you have a class with a public member, say

class CMyClass
{
public:
   int iNo;
};

Then you can access iNo as

CMyClass myClass;
myClass.iNo = 10;

Is it something that you really mean?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.