#include <iostream>
usingnamespace std;
class tmp2
{
public:
void test()
{
cout<<"we are now in the function 'test'"<<endl;
return;
}
};
class tmp
{
public:
staticint hoofd()
{
cout<<"this is in 'hoofd'"<<endl;
tmp2 k;
k.test();
cout<<"this was the einde"<<endl;
return 0;
}
};
int main()
{
tmp::hoofd();
return 0;
}
Look at the main-function. i've declared a member method to be static. bu why do i have to write tmp::hoofd, and not tmp.hoofd??
please answer quick
. is used to access data in a specific object (e.g. object.member) and to pass objects as the this parameter to functions (e.g. object.function()).
:: is used for scope resolution.
There is no technical reason for not doing it like you say, but this way is just more coherent.