【发布时间】:2012-05-27 07:05:05
【问题描述】:
如何在一个类中调用一个方法而不是使用另一个类?
我有;
class A {
public :
foo ( ) ;
};
class B {
public :
bar ( ) ;
};
主要:
A data ; // I am creating instance of class A
data . bar ( ) ; // but, I am calling a method of another class
// how can I do that ?
注意:我找不到合适的标题。如果您有,请随时分享或编辑
【问题讨论】:
-
派生类的快速参考可能会有所帮助。 en.cppreference.com/w/cpp/language/derived_class
标签: c++ oop class function function-call