C++:一个类中的成员函数如何调用该类中的另一个成员函数,还没实例化

如题所述

跟普通的函数一样的,只要调用的在被调用的后面即可。
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-09-07
直接用函数名调就行了。例如:
class A
{
void fa(int k) {...}
void fb(int m)
{
fa(m);

}

}
第2个回答  2013-09-08
什么意思?
class A{
void f1(){...}
void f2(){...}
};
是f1要调用f2?直接在函数体里写调用就行了f1(){...f2();...}
第3个回答  2013-09-07
想法根本就有问题
第4个回答  推荐于2016-05-29
1 #include <iostream>
2 using namespace std;
3 class a{
4 public:
5 a(int i):value(i){
6 }
7 int f1();
8 int f2();
9 private:
10 int value;
11 };
12 int a::f1(){
13 cout << "f1" << endl;
14 }
15 int a::f2(){
16 this->f1(); 这里调用
17 cout << "the value is " << value << endl;
18 }
19 int main(){
20 a a1(100);
21 a1.f1();
22 a1.f2();
23 return 0;
24 }本回答被提问者采纳
相似回答