B
beerbal
Hello,
I am a bit confused as to how the following snippet would work?
#include <iostream>
class Foo
{
public:
void doSomething()
{
std::cout << "Foo::doSomething()\n";
}
};
int main()
{
Foo* ptr;
ptr->doSomething();
return 0;
}
I compiled this with both g++ and VC and in both cases, program printed
Foo::doSomething() when run.
My question is, since ptr is declared as just a pointer to class Foo,
how/why does the call to doSomething() go thru' even when there is no
object created explicitly?
Thanks,
Beerbal
I am a bit confused as to how the following snippet would work?
#include <iostream>
class Foo
{
public:
void doSomething()
{
std::cout << "Foo::doSomething()\n";
}
};
int main()
{
Foo* ptr;
ptr->doSomething();
return 0;
}
I compiled this with both g++ and VC and in both cases, program printed
Foo::doSomething() when run.
My question is, since ptr is declared as just a pointer to class Foo,
how/why does the call to doSomething() go thru' even when there is no
object created explicitly?
Thanks,
Beerbal