A
Aguilar, James
I want to call a constructor from another constructor without constructing
an object. In other words, I want to partially initialize the object I'm
working with with one constructor, and finish the job with another.
class Foo
{
public:
Foo();
Foo(int i);
private:
int a, b;
};
Foo::Foo()
{
a = b = 0;
}
Foo::Foo(int i)
{
Foo(); //or should it be Foo::Foo()?
a = i;
}
Is there any way to do this in C++ that does not involve private helper
methods?
an object. In other words, I want to partially initialize the object I'm
working with with one constructor, and finish the job with another.
class Foo
{
public:
Foo();
Foo(int i);
private:
int a, b;
};
Foo::Foo()
{
a = b = 0;
}
Foo::Foo(int i)
{
Foo(); //or should it be Foo::Foo()?
a = i;
}
Is there any way to do this in C++ that does not involve private helper
methods?