vscode不同cpp文件中类的调用(C++)

您所在的位置:网站首页 一个类使用另一个类 vscode不同cpp文件中类的调用(C++)

vscode不同cpp文件中类的调用(C++)

2024-07-12 19:22| 来源: 网络整理| 查看: 265

一个类的声明 //student.cpp class student { private: /* data */ public: double getDoubleAge(double age); student(/* args */); ~student(); }; student::student(/* args */){} student::~student(){} double student::getDoubleAge(double age) { return age*2; } 若要在其他cpp文件中调用这个类

方法一:直接调用cpp文件 头文件声明中直接添加需要调用的类的cpp文件 示例如下:

//student.cpp #include #include "student.cpp" using namespace std; int main() { student S; double age = S.getDoubleAge(15); cout


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3