Paste: 123
Author: | 123 |
Mode: | c++ |
Date: | Mon, 25 Sep 2023 13:20:23 |
Plain Text |
#include <iostream>
using namespace std;
class Component
{
private:
int com1;
public:
Component() {
cout<<"c Component k"<<endl;
};
Component(int com1)
: com1(com1) {
cout<<"c Component"<<endl;
};
~Component(){
cout<<"~Component"<<endl;
};
};
class Derived
{
private:
int der1;
Component com1;
Component com2;
public:
Derived(int der1=0,Component com1={1},Component com2={2})
: der1(der1),com1(com1),com2(com2)
{cout<<"c Derived"<<endl;};
// Derived()
// // : der1(der1)
// {cout<<"c Derived 2"<<endl;};
~Derived(){
cout<<"~Derived"<<endl;
};
};
class Derived2
{
private:
int der1;
Component com1;
Component com2;
public:
Derived2() {
cout<<"c Derived2 k"<<endl;
};
Derived2(int der1,Component com1,Component com2)
: der1(der1),com1(com1),com2(com2)
{cout<<"c Derived2"<<endl;};
// Derived()
// // : der1(der1)
// {cout<<"c Derived 2"<<endl;};
~Derived2(){
cout<<"~Derived2"<<endl;
};
};
int main (void)
{
{
Derived d1;
Derived2 d2;
cout<<"-----------"<<endl;
}
// delete d1;
// {
// Base b1;
// }
return 0;
}
New Annotation