以下是简单的c+中成员函数普通函数的声明与定义实例源码:
#include<iostream>
using namespace std;
//c++普通函数的声明
void puTong();
void puTong(){//c++定义普通函数
cout<<”我是普通函数;\n”;
}
class Human{//定义Human类
public:
void chengYuan();//定义公共成员函数
};
void Human::chengYuan(){//c++定义成员函数
cout<<”我是成员函数;\n”;
}
int main()
{
puTong();
Human xiaoDong;//c++声明对象
xiaoDong.chengYuan();//c++通过对象调用成员函数
return 0;
}
本文链接地址: c+中成员函数普通函数的声明与定义实例源码