Thursday, September 8, 2011

Anonymous Objects

It is possible to construct anonymous objects for our own class types. This is done by creating objects like normal, but omitting the variable name.

1Cents cCents(5); // normal variable
2Cents(7); // anonymous variable
In the above code, Cents(7) will create an anonymous Cents object, initialize it with the value 7, and then destroy it.

No comments: