asd.cpp

来自「visual c++ and Mfc 代码」· C++ 代码 · 共 42 行

CPP
42
字号
#include <iostream> 
using namespace std; 
class test 
{ 
private: 
int number; 
public: 
float socre; 
int pp; 
public: 
int rp(int); 

 
}; 
int test::rp(int a)//在外部利用域区分符定义test类的成员函数 
{ 
number=0; 
return a + number; 
} 

 

void run(test *p)//利用指针调用 
{ 
cout<<p->rp(100)<<endl; 
} 
void run(test &p)//利用引用 
{ 
cout<<p.rp(200)<<endl; 
} 

 
void main() 
{ 
	test a; 
	run(&a);          
	run(a);            
	cin.get(); 
} 


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?