#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;

#include <iostream>

using namespace std;

class A {
public:
    static vector<A*> A_vector;
    int x, y, z;

    A() {
        this->x = 0;
        this->y = 0;
        this->z = 0;
        A_vector.push_back(this);
    }

    ~A() { }

    void init(int x_in, int y_in, int z_in) {
        this->x = x_in;
        this->y = y_in;
        this->z = z_in;
    }

    int sum() {
        return this->x + this->y + this->z;
    }

    void show_result() {
        int result = sum();
        cout << "sum = " << result << endl;
    }
};
vector<A*> A::A_vector;


class B {
public:
    A A_car, A_cat, A_canada;

    B() {
        A_car.init(0, 1, 2);
        A_cat.init(1, 2, 3);
        A_canada.init(8, 7, 6);
    }

    ~B() {}

    void show_all_result() {
        for (int i = 0; i < A::A_vector.size(); i++)
            A::A_vector[i]->show_result();
    }
};


int main() {

    B obj_B;

    obj_B.show_all_result();
    printf("done\n");
    return 0;
}

