You don’t want to addAndMakeVisible to locally created objects. First, they go out of scope when you exit out of the routine since they are created on the stack. Second, the destructor for a component deletes any added children and it will be deleting an invalid pointer.
The best way to add components is always to dynamically allocate them:
Component c = new Component(T("My Component"));
c->setBounds(100, 100, 400, 300);
If you have another component already allocated somewhere else and don’t want it deleted automatically after adding it to the main component, call in the parent component’s destructor:removeChildComponent(c);