Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. // Example program
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. class D{
  8.     public:
  9.         D() {cout << "D0 ";}
  10.         D(int a) {cout << "D1 ";}
  11. };
  12.  
  13. class E{
  14.     private:
  15.     D d;
  16.     public:
  17.     E() : d(3) {cout << "E0 ";}
  18.     E(double a, int b) {cout << "E2 ";}
  19.     E(const E& a) : d(a.d) {cout << "Ec ";}
  20. };
  21.  
  22. class C{
  23.   private:
  24.   int z;
  25.   E e;
  26.   D d;
  27.   E* p;
  28.   public:
  29.   C() : p(0), e(), z(4) {cout << "C0 ";}
  30.   C(int a, E b) : e(3.7, 2), p(&b), z(1), d(3) {cout << "C1 ";}
  31.   C(char a, int b) : e(), d(2), p(&e) {cout << "C2 ";}
  32. };
  33.  
  34.  
  35. int main()
  36. {
  37.     E e; cout << endl;
  38.     C c; cout << endl;
  39.     C c1(1, e); cout << endl;
  40.     C c2('b', 2); cout << endl;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement