class draw
{
draw(circle i)
{
// draw a circle;
}
draw(circle i, circle j)
{
draw(i);
draw(j);
}
}
Can I call another overloaded constructor of the same class in C++ even if using template?
class draw
{
draw(circle i)
{
// draw a circle;
}
draw(circle i, circle j)
{
draw(i);
draw(j);
}
}
Can I call another overloaded constructor of the same class in C++ even if using template?
No, in C++ you cannot have one constructor directly call another (well, at least not more than once). However, you can have each constructor call a third method that performs actual work.
class draw
{
draw(circle i)
{
do_draw(i);
}
draw(circle i, circle j)
{
do_draw(i);
do_draw(j);
}
void do_draw(circle c)
{
// draw a circle;
}
}