Paste: 123

Author: 33
Mode: c++
Date: Mon, 25 Sep 2023 03:03:00
Plain Text |
#include <iostream>

using namespace std;

class Component
{
private:
    int com1;
public:
    Component(int com1)
    : com1(com1) {
        cout<<"c Component"<<endl;
    };
    ~Component(){
        cout<<"~Component"<<endl;
    };
};


class Base
{
private:
    /* data */
    int base1;
public:
    Base(int base1=1)
    : base1(base1)
    { cout<<"c Base"<<endl;};

    ~Base(){
        cout<<"~Base"<<endl;
    };
};

class Derived:public Base
{
private:
    int der1;
    Component com1;
public:
    Derived(int der1=0,Component com1={1})
    : der1(der1),com1(com1)
    {cout<<"c Derived"<<endl;};

    // Derived()
    // // : der1(der1)
    // {cout<<"c Derived 2"<<endl;};

    ~Derived(){
        cout<<"~Derived"<<endl;
    };
};






int main (void)
{

    Derived d1(1);
    return 0;
}

New Annotation

Summary:
Author:
Mode:
Body: