c++11 - Exposing member variables methods in C++ -


i have simple object-components design. like:

class object1 : public object {     component1 _comp1;     component2 _comp2;     ...     componentn _compn; }; 

is possible expose public: methods of objects1 methods componentk without creating method in object1 calls internally componentk method?

i need simple way of doing because it's quite annoying write function every time want expose componentk method.

not directly, no. use private inheritance inherit components instead of aggregating them (note private inheritance not express is-a), , publish of member functions using. this:

class object1 : public object, private component1, private component2, ..., private componentn { public:   using component1::function1();   using component1::function2();   ...   using componentn::functionm(); }; 

i'm not saying it's best way it, it's a way.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -