4
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by Radical Edward
0

Not possible. The programmer can create it either on the stack or on the heap -- the choice is up to him/her. The object has no idea where it is in memory.

0

Although that compiles I don't think it will run. This should cause a coredump or crash because it uses an uninitialized pointer

int main()
{
    A *a;
    a->create();
}
1

> This should cause a coredump or crash because it uses an uninitialized pointer
Yes, but normally a static method is called using the class name when it cannot be called on an object.

A *a = A::create();
Votes + Comments
Great :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.