is there a way to have a default Object for parameters in C++ functions? I tried
void func(SomeClass param = new SomeClass(4)); and it worked. However how would I am I supposed to know wheter I have to free the allocated memory in the end? I would like to do the same without pointers, just an Object on the stack. is that possible?
void func(SomeClass param = SomeClass(4));. Your function will receive SomeClass object by value and will destroy it automatically after the function callnew SomeClass(4)returning a pointer to SomeClass while the function expect an instance. but without thenewthere is no problem. +1 since I never thought of trying this before.SomeClass( void * )There's a train-wreck waiting to happen.