A doubt about static functions in a Class
I had basically 2 doubts about them.
1)If I create a class A as:
1 2 3 4 5 6 7 8 9
|
class A
{
public:
int num;
static void rNum() {return num;}
}a,b;
//..............
cout << rNum();
//..............
|
This is assuming, num in both a & b have been assigned, what will happen?
2)If I create two classes as:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
class A
{
public:
static void func() {/*Does something*/}
}
class B
{
public:
static void func() {/*Does something Else*/}
}
//.....................
func();
//.....................
|
Again what will happen?
The compiler will complain that static functions cannot access non static members
The compiler will complain that function 'func()' is unknow. To access either func() write 'A::func();' or 'B::func();'
Ah! Thanks a Lot!
That clears it up.
Thanks again...
Topic archived. No new replies allowed.