1234567891011121314151617181920212223242526272829
class A { public: A(double value) : variable(value) {} double accessorFunction() const {return variable;} private: double variable; }; class B { public: B(double x) : anotherVariable(x) {} private: double anotherVariable; }; int main() { A Object(3.0); //A::variable is now 3.0 B AnotherObject(Object.accessorFunction()); //now B::anotherVaiable = 3.0 return 0; }