#include <iostream>
using namespace std;
class MyBase1
{
public:
MyBase1() {
cout << "Con1\t" << this << endl;
}
MyBase1(const MyBase1 &other) {
cout << "CCon1\t" << this << endl;
}
~MyBase1() {
cout << "Des1\t" << this << endl;
}
};
class MyBase2
{
public:
MyBase2() {
cout << "Con2\t" << this << endl;
}
MyBase2(const MyBase2 &other) {
cout << "CCon2\t" << this << endl;
}
~MyBase2() {
cout << "Des2\t" << this << endl;
}
};
class MyBase12 : public MyBase1, MyBase2
{
public:
MyBase12() {
cout << "Con12\t" << this << endl;
}
MyBase12(const MyBase12 &other) {
cout << "CCon12\t" << this << endl;
}
~MyBase12() {
cout << "Des12\t" << this << endl;
}
};
class MySuperClass : public MyBase12
{
public:
MySuperClass() {
cout << "ConS\t" << this << endl;
}
MySuperClass(const MySuperClass &other) {
cout << "CConS\t" << this << endl;
}
~MySuperClass() {
cout << "DesS\t" << this << endl;
}
};
void func(MyBase12 r)
{
cout << "COPY:\t" << &r << endl;
}
int main()
{
const char *delim = "*****************\n";
MySuperClass o;
cout << "ORIG:\t" << &o << endl << delim;
func(o);
cout << delim;
}
gcc версия 4.5.2 20110127 (prerelease) (GCC) x86_64
Con1 0x7fff30141e66
Con2 0x7fff30141e66
Con12 0x7fff30141e66
ConS 0x7fff30141e66
ORIG: 0x7fff30141e66
*****************
Con1 0x7fff30141e67
Con2 0x7fff30141e67
CCon12 0x7fff30141e67
COPY: 0x7fff30141e67
Des12 0x7fff30141e67
Des2 0x7fff30141e67
Des1 0x7fff30141e67
*****************
DesS 0x7fff30141e66
Des12 0x7fff30141e66
Des2 0x7fff30141e66
Des1 0x7fff30141e66
MSVC++ 2010 Express
Con1 0012FF4B
Con2 0012FF4C
Con12 0012FF4B
ConS 0012FF4B
ORIG: 0012FF4B
*****************
Con1 0012FE60
Con2 0012FE61
CCon12 0012FE60
COPY: 0012FE60
Des12 0012FE60
Des2 0012FE61
Des1 0012FE60
*****************
DesS 0012FF4B
Des12 0012FF4B
Des2 0012FF4C
Des1 0012FF4B