Assume I have:
class A {
int i;
}
class B : public A {
int j;
A base() { return *this; }
}
Is this legal C++ ? Or will I run into slicing problems?
Assume I have:
class A {
int i;
}
class B : public A {
int j;
A base() { return *this; }
}
Is this legal C++ ? Or will I run into slicing problems?
Is this legal C++ ?
Yes.
Or will I run into slicing problems?
Slicing is exactly what is being done here. Whether there is a problem or not is subjective.
There is not explicit constructor
There is no need for an explicit constructor since the copy constructor is generated implicitly.