Reputation: 211
header of CMain
CSomeClass a
using CSomeClass inside CMain.cpp
a.SomeFunction();
a.m_bVar = SomeVar;
the question is, how do i get a different, second instance of CSomeClass that uses the same varables inside CSomeClass but with their own individual values without the use of new?
i know pSomePointer = new CSomeClass[2];
will make a different instance, but is it possible without using new?
Upvotes: 1
Views: 80
Reputation: 178411
Yes it is,
CSomeClass myObjects[2];
will create two automatically allocated objects.
Upvotes: 0
Reputation: 545508
CSomeClass b;
Just declare a new variable.
Furthermore, a
probably shouldn’t be defined inside a header but also inside CMain.cpp
, just where you need it.
Upvotes: 2