#include <iostream>
#include <cstring>
using namespace std;
class Base
{
public:
Base()
: value_(10)
, hoge_(20)
{
cout << "Base::Base()" << endl;
}
virtual ~Base() {
cout << "Base::~Base()" << endl;
}
void print() {
cout << value_ << endl;
}
private:
int value_;
int hoge_;
};
class Derivation : public Base
{
public:
Derivation()
: value_(100)
, hoge_(10)
{
cout << "Derivation::Derivation()" << endl;
}
virtual ~Derivation() {
cout << "Derivation::~Derivation()" << endl;
}
void print() {
cout << value_ << endl;
}
private:
int value_;
int hoge_;
};
int main()
{
cout << "Base:" << sizeof(Base) << endl;
cout << "Derivation:" << sizeof(Derivation) << endl;
Base* d = new Derivation[10];
for (int i = 0; i < 10; ++i) {
d[i].print();
}
delete [] d;
return 0;
}