if so how? I saw this in java, i watned to do this too in C++,
ie,
class a
{
afunction
};
a.afunction(...) // when using,
many thanks :)
if so how? I saw this in java, i watned to do this too in C++,
ie,
class a
{
afunction
};
a.afunction(...) // when using,
many thanks :)
Declare the member function as static and use scope resolution :
Just note that no non-static member functions or member variables should be used.Code:class a
{
public :
static void test()
{
cout << "hallo";
}
};
int main()
{
a::test();
return 0;
}
wow, thanks!! :)
just wondering if this is the 'only' and standard way to do this? because i don't remember encountering this stuff when i was reading my c++ book,
thanks, that'll be my last question i hope, :)
yes its the only way. You can call a static function without an object. You cannot do this with other member functions because they must send a this pointer.
alright thanks!! :)