Assume I have this:
class foo{
Member member;
foo();
~foo();
};
How I should allocate the member?
EDIT: How should I tell him which constructor to use?(sorry for being unclear)
Now I already know about the member = Member(...); syntax
Will this cause memory leak?
{
Memory *temp = new Member();
member = *(temp); //will it work at all??(is it copy constructor?)
delete temp;
}
C++ is not Java. This member is already allocated. It is part of the memory of the instance it is in. It will get constructed (initialized) by the constructor of the containing instance. The key word new has nothing to do with a member that is not a pointer.