#include <iostream>
#include <utility>
using namespace std;

// ==========================
template <typename F>
void apply(F&&) {}

template <typename F, typename First, typename... Rest>
void apply(F&& f, First&& first, Rest&&... rest) {
  std::forward<F>(f)(std::forward<First>(first));

  apply(std::forward<F>(f), std::forward<Rest>(rest)...);
}
// ==========================



class A{
public:
    int x, y, z;

    A() {
        this->x = 0;
        this->y = 0;
        this->z = 0;
    }
    
    ~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;
    }
};



#define PP_MEMBER_LIST A_CAR, A_CAT, A_CANADA

class B {
public:
    A PP_MEMBER_LIST;

    B() {
        A_CAR.init(0, 1, 2);
        A_CAT.init(1, 2, 3);
        A_CANADA.init(8, 7, 6);
    }
    
    ~B() {}
    
    void show_all_result() {
    	const auto show_result = [](A& a) { a.show_result(); };
    	
    	apply(show_result, PP_MEMBER_LIST);
    }
};


int main() { 

    B obj_B;

    obj_B.show_all_result();
}
