Hello,
please see these codes
CODE
#include<iostream>
using namespace std;
class A
{
public:
static void sayHello()
{
cout<<"Hello World!!!";
}
void SayHwztht()
{
cout<<"hwz that possible!!!";
}
};
int main()
{
A* ab;
ab = NULL; //i have just declaterd a pointer there is no actual
//object created as i havent used a 'new' for doing same
ab->sayHello();
ab->SayHwztht();
system("pause");
return 0;
}
its being said in C++ tht the object encapsulates the member funtions and the member variables, that is whenever a object is created new copy of those member var and func is also generated but if we have a static member function only the defination exist in class but not in all objects
so as by the rule
CODE
ab->sayHello();
should have worked as it is a static member but
CODE
ab->SayHwztht();
should not work as it is not static and i haven't made ne new object yet only pointer/refrence
o->when i made the same prog in JAVA, JAVA gave me error

saying that sayHwztht() can not be accessed and as expeccted sayHello() worked as its static
o->I used DEVCpp 4.9.9.2, VS2005, VS98 all gave same result
and the result is
CODE
Hello World!!!hwz that possible!!!Press any key to continue . . .
Y is that i can access both functions???