|
From: Daniel K. O. <dan...@ya...> - 2004-10-29 16:04:51
|
--- Noorez Kassam <dar...@ho...>
escreveu:
> class Test2
> {
>
> public:
> Test2()
> {
> t = ...
> }
>
> Test t;
> };
>
> When I created an object of type Test2 it jumped to
> the constrctor like it
> should have but than it called the constructor
> twice. Once with the default
> constructor before entering the body and again when
> doing the line t=....
And that's the correct behaviour. Inside the
constructor, every member must be already constructed.
If you want to change the way the members are
constructed (like passing arguments for the
constructors) you should use:
Test2::Test2() : t(arg1, arg2, ...)
{
}
Recomendation: read The C++ Programming Language,
you'll have a much happier experience with C++.
Daniel K. O.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|