D
Dave Rudolf
Hi all,
At the risk of mentioning Java in a C++ news group , I'm curious if there
is a way to reuse constructors in C++ similar to what can be done in Java.
For instance, in java, I can do the following:
public class Rectangle
{
public Rectangle( int width, int height )
{
// Do stuff here
}
public Rectangle( int widthAndHeight )
{
this( widthAndHeight , widthAndHeight );
}
}
That is, the second constructor simply calls the first to do all of the
dirty work. Is there some similar concept in C++? Certainly, a direct
translation does not work.
Dave
At the risk of mentioning Java in a C++ news group , I'm curious if there
is a way to reuse constructors in C++ similar to what can be done in Java.
For instance, in java, I can do the following:
public class Rectangle
{
public Rectangle( int width, int height )
{
// Do stuff here
}
public Rectangle( int widthAndHeight )
{
this( widthAndHeight , widthAndHeight );
}
}
That is, the second constructor simply calls the first to do all of the
dirty work. Is there some similar concept in C++? Certainly, a direct
translation does not work.
Dave