I'm trying to create a class with an object field. I want to create the object on the stack rather than the heap, but when I define it, it seems to call the default constructor because when I try to set it inside the class constructor to an object instantiated with another overload of the field's constructor it tries to call the copy constructor on the field.
The type of the field doesn't have a copy constructor, so what I'm asking is whether there's a way to define the property in the class and call the correct constructor overload (with parameters) without having to instantiate the object with the default parameter and then use the copy constructor to assign it?
If possible I'd like to avoid having to new the object and store a reference.
1 2 3 4 5 6 7 8 9 10 11
testObject = Test(52);
// This tries to call the copy constructor.