|
-
April 4th, 2010, 12:00 AM
#1
Why does this work?
A dynamic object but we assign it the value NULL...So our object is NULL but we can still call the member function showthis() and it works, but why?
#include <iostream>
class myc
{
public:
myc() {}
~myc() {}
void showthis() const {std::cout<<"Hello, World!"<<"\n";}
private:
};
int main(int argc, char**argv)
{
myc *thec = (myc*)NULL;
std::cout<<"address of thec->"<<(void*)thec<<"\n";
thec->showthis();
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|