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

flash做ppt的模板下载网站有哪些网站建设个人

flash做ppt的模板下载网站有哪些,网站建设个人,asp网站访问量大,网站建设功能评价指标每一个.cpp文件经过编译之后都会生成对应的.obj文件#xff0c;然后通过链接器把它们进行链接#xff0c;最后就可以生成.exe可执行文件了。 举个例子#xff0c;假设我们有一个 Math.cpp 文件和 Log.cpp 文件#xff1a; Math.cpp #include iostreamvoid Log(c…每一个.cpp文件经过编译之后都会生成对应的.obj文件然后通过链接器把它们进行链接最后就可以生成.exe可执行文件了。 举个例子假设我们有一个 Math.cpp 文件和 Log.cpp 文件 Math.cpp #include iostreamvoid Log(const char* message); // 声明int Multiply(int a, int b) {Log(Multiply);return a * b; }int main() {std::cout Multiply(5, 8) std::endl;std::cin.get(); }Log.cpp #include iostreamvoid Log(const char* message) // 定义 {std::cout message std::endl; }直接按 F5 进行编译和链接可以正常运行。但如果我们把 Log.cpp 中的函数名改为 Logr如下 #include iostreamvoid Logr(const char* message) // 定义 {std::cout message std::endl; }就会出现无法解析的外部命令错误这是因为链接器无法找到函数 Log 的定义。 如果我们注释掉 Math.cpp 的 Multiply 函数中对 Log 函数的调用就不会报错这是因为 Log 函数没有被任何地方调用也不可能被调用 #include iostreamvoid Log(const char* message); // 声明int Multiply(int a, int b) {//Log(Multiply);return a * b; }int main() {std::cout Multiply(5, 8) std::endl;std::cin.get(); }但如果我们注释掉 Math.cpp 中 main 函数对 Multiply 函数的调用而保留 Multiply 函数中的 Log 函数就会报错这是因为虽然当前文件中 Log 函数没有被调用但它是有可能在其他文件中被调用的 #include iostreamvoid Log(const char* message);static int Multiply(int a, int b) {Log(Multiply);return a * b; }int main() {//std::cout Multiply(5, 8) std::endl;std::cin.get(); }解决方法是给 Multiply 函数加上 static 表明这个函数只能在当前文件 Math.cpp 被调用。 另一个最常见的错误就是重复定义即使是看上去好像只定义了一次如下例 Log.h void Log(const char* message) {std::cout message std::endl; }Log.cpp #include iostream #include Log.hvoid InitLog() {Log(Initialized Log); }Math.cpp #include iostream #include Log.hint Multiply(int a, int b) {Log(Multiply);return a * b; }int main() {std::cout Multiply(5, 8) std::endl;std::cin.get(); }对两个cpp文件进行编译之后点击链接Build就会报错 这个 LINK 开头的错误就是链接错误它说 Math.obj 中的 Log 函数已经在 Log.obj 中定义了出现多次定义但是我明明只在 Log.h 中定义了一次呀为什么会这样呢 回想之前我们对#include的功能介绍它就是复制头文件的内容然后粘贴到它所在的位置所以实际上我们的两个 cpp 文件经过预处理之后会变成这样 Log.cpp #include iostream void Log(const char* message) {std::cout message std::endl; }void InitLog() {Log(Initialized Log); }Math.cpp #include iostream void Log(const char* message) {std::cout message std::endl; }int Multiply(int a, int b) {Log(Multiply);return a * b; }int main() {std::cout Multiply(5, 8) std::endl;std::cin.get(); }显然我们确实多次定义了 Log 函数那有什么解决方法呢 方法一 在Log.h中定义的Log函数前加上static如下 static void Log(const char* message) {std::cout message std::endl; }这样Log函数在两个cpp文件就是各自为政了不会发生冲突。 方法二 在Log.h中定义的Log函数前加上inline如下 inline void Log(const char* message) {std::cout message std::endl; }inline的效果就是在调用函数的地方直接用函数内容进行替换再执行如 Log.cpp #include iostream #include Log.hvoid InitLog() {Log(Initialized Log); }会变成这样 #include iostream #include Log.hvoid InitLog() {std::cout Initialized Log std::endl; }方法三 这是最为常用的方法就是不要在头文件中定义函数把定义搬到一个的cpp文件就行了 Log.h void Log(const char* message)Log.cpp #include iostream #include Log.hvoid Log(const char* message) {std::cout message std::endl; }void InitLog() {Log(Initialized Log); }Math.cpp #include iostream #include Log.hint Multiply(int a, int b) {Log(Multiply);return a * b; }int main() {std::cout Multiply(5, 8) std::endl;std::cin.get(); }
http://www.zqtcl.cn/news/468980/

相关文章:

  • 深圳建设网站哪家最好国外互联网裁员
  • 网站重新建设的请示wordpress get_terms 排序
  • 建站模板免费下载wordpress 管理地址
  • 静安企业网站制作wordpress文章列表显示缩略图
  • html前端网站开发先做网站还是先解析
  • 怎么通过域名访问网站elision wordpress
  • 做邮轮的网站做游戏的软件app
  • 做网站用php还是python家装十大品牌排行榜
  • 湛江网站建设招聘创作者服务平台
  • 衡阳建网站高中制作网站怎么做
  • 上海网站排名团队推广链接跳转
  • 寻找郑州网站优化公司上海高端网站定制
  • 网站关键词排名优化长城建设投资有限公司网站
  • 网站专题优化电子商务网站运营方案
  • 唐山建网站公司湖南网站制作电话
  • 做神马网站优化合肥城乡建设局官网
  • 网站开发与管理心得体会建设高流量网站
  • 网站安全建设的重要性减粘装置设备设计要点
  • 建设一个网站的所有代码Django和wordpress速度
  • 临沂市建设局网站公示php建站系统
  • 有哪些好的做问卷调查的网站好学的专业是编课 网站开发英语翻译
  • 个人网站免费推广广饶网站制作
  • 怎么检测网站是否安全拍卖网站开发
  • 沂源网站制作自建网站的流程
  • 网站关键词收录查询网站最好服务器
  • 做百度移动网站优网站建设类论文选题
  • 自己做的网站怎样让百度搜到长沙专业外贸建站公司
  • 上海缔客网站建设公司网站策划书内容不包括什么
  • 找团队做网站网站建设 通知
  • 网站标题上的小图标怎么做的霞浦建设局网站