当前位置: 首页 > news >正文

帮助做职业规划的网站星沙网站优化seo

帮助做职业规划的网站,星沙网站优化seo,坪山区住房和建设局网站,做网站能不能赚钱demo1只有类的情况下调用 下面写一个util.h 文件里面 // 定义宏防止编译器重复编译 #ifndef TEST_H #define TEST_H class Test{ public:void sum(int a, int b);int num(int a, int b);bool number();}; #endif // TEST_H 调用的时候首先要引入这个头文件 #include "u…

demo1只有类的情况下调用

下面写一个util.h 文件里面

// 定义宏防止编译器重复编译
#ifndef TEST_H
#define TEST_H
class Test{
public:void sum(int a, int b);int num(int a, int b);bool number();};
#endif // TEST_H

调用的时候首先要引入这个头文件 #include "util.h"

cpp 里面实现

#include <iostream>
#include <string>
#include "util.h"
using namespace std;// 实现Test类的sum成员函数
void Test::sum(int a,int b){cout << "The sum of " << a << " and " << b << " is: " << a + b << std::endl;
}
// 实现Test类的num成员函数
int Test::num(int a, int b) {return a * b;
}
// 实现Test类的number成员函数
bool Test::number() {return true;
}int main() {int a =3;int b =6;Test test;test.sum(a,b);int result = test.num(a,b);cout<< "num result" << result <<endl;bool isNumber = test.number();cout<< "number result" << isNumber <<endl;return 0;
}

demo2 有namespace的情况下调用

util.h 文件

// 定义宏防止编译器重复编译
#ifndef TEST_H
#define TEST_H
namespace common::comm::com {
class Test{
public:void sum(int a, int b);int num(int a, int b);bool number();};
}
#endif  

cpp 里面实现,这里不使用using namespace

#include <iostream>
#include <string>
#include "util.h"
using namespace std;// 实现Test类的sum成员函数
void common::comm::com::Test::sum(int a,int b){cout << "The sum of " << a << " and " << b << " is: " << a + b << std::endl;
}
// 实现Test类的num成员函数
int common::comm::com::Test::num(int a, int b) {return a * b;
}
// 实现Test类的number成员函数
bool common::comm::com::Test::number() {return true;
}int main() {int a =3;int b =6;common::comm::com::Test test;test.sum(a,b);int result = test.num(a,b);cout<< "num result" << result <<endl;bool isNumber = test.number();cout<< "number result" << isNumber <<endl;return 0;
}

使用using namespace

namespace common::comm::com {
// 实现Test类的sum成员函数
void Test::sum(int a,int b){cout << "The sum of " << a << " and " << b << " is: " << a + b << std::endl;
}
// 实现Test类的num成员函数
int Test::num(int a, int b) {return a * b;
}
// 实现Test类的number成员函数
bool Test::number() {return true;
}
}
int main() {int a =3;int b =6;using namespace common::comm::com;Test test;test.sum(a,b);int result = test.num(a,b);cout<< "num result" << result <<endl;bool isNumber = test.number();cout<< "number result" << isNumber <<endl;return 0;
}

实际用不用,根据个人习惯即可,不使用using namespace在每次调用时都写出完整的命名空间路径

把util.h 文件修改一层一层的

// 定义宏防止编译器重复编译
#ifndef TEST_H
#define TEST_H
namespace common{namespace comm{namespace com{class Test{public:void sum(int a, int b);int num(int a, int b);bool number();};}}
}
#endif  

实现里面的方法效果也是一样的

#include <iostream>
#include <string>
#include "util.h"
using namespace std;namespace common::comm::com {
// 实现Test类的sum成员函数
void Test::sum(int a,int b){cout << "The sum of " << a << " and " << b << " is: " << a + b << std::endl;
}
// 实现Test类的num成员函数
int Test::num(int a, int b) {return a * b;
}
// 实现Test类的number成员函数
bool Test::number() {return true;
}
}
int main() {int a =3;int b =6;using namespace common::comm::com;Test test;test.sum(a,b);int result = test.num(a,b);cout<< "num result" << result <<endl;bool isNumber = test.number();cout<< "number result" << isNumber <<endl;return 0;
}

或者

#include <iostream>
#include <string>
#include "util.h"
using namespace std;namespace common {namespace comm {namespace com {// 实现Test类的sum成员函数void Test::sum(int a, int b) {std::cout << "The sum of " << a << " and " << b << " is: " << a + b << std::endl;}int Test::num(int a, int b) {return a * b;}bool Test::number() {return true; // 示例返回true}} // 结束命名空间 com} // 结束命名空间 comm
} // 结束命名空间 common
int main() {int a =3;int b =6;using namespace common::comm::com;Test test;test.sum(a,b);int result = test.num(a,b);cout<< "num result" << result <<endl;bool isNumber = test.number();cout<< "number result" << isNumber <<endl;return 0;
}

http://www.zhongyajixie.com/news/16756.html

相关文章:

  • 江苏网站seo优化品牌营销与推广
  • 免费制作主图的网站长沙网络推广服务
  • 那个网站可以做双色球号码对比的seo站外优化平台
  • 北京b2c网站制作关键词歌词含义
  • 迁安市住房和城乡建设局网站官网站内推广内容
  • 微平台推广多少钱广州seo关键词优化是什么
  • 美工培训中心简述seo和sem的区别
  • 网站规划的内容网站底部友情链接
  • 在线网址免费的seo排名培训学校
  • 网站建设公司做前端网站搜索引擎优化的步骤
  • 电子商务网站建设课程设计报告seo服务商排名
  • 怎么做离线网站公司网站推广费用
  • 用手机怎么做网站企业营销推广方案
  • 免费二级网站seo关键字优化
  • 3g 手机网站深圳网站优化网站
  • 网站建设公司哪家企业网站建设方案书
  • 营销型网站建设的特色网上广告宣传怎么做
  • html5手机网站开发视频搭建一个网站平台需要多少钱
  • dw软件网站建设教程视频seo是什么姓
  • 免费ps模板下载网站品牌营销策划公司排名
  • 在b2c电商网站上购物时提供的送货推广广告
  • 网站添加视频免费seo工具
  • 做跨境网站注意事项链接交换
  • .net网站设计知名网站
  • 科技成果转化网站建设百度官方免费下载安装
  • 怎么注册网自己的网站网店推广网站
  • 1688一件代发批发网郑州网络seo公司
  • 做网站最好的软件上海seo网站优化软件
  • 为什么一个网站做中英文双语版外贸平台有哪些比较好
  • 个人网站效果图咋做中国十大门户网站排行