[Solved] C++ Accessing Another Class Member [closed]
Simply add a getter method int get_x() to Class1 #include <iostream> #include <conio.h> using namespace std; class Class1{ private: int x; public: Class1(); void Display(); int get_x(); }; int Class1::get_x() { return x; } class Class2{ private: double z; public: Class2(); void Display(); Class2 Add(Class1); }; Class1::Class1(){ x = 1; } Class2::Class2(){ z = 5; … Read more