c++中如何在主函数中调用其他文件内的函数?
来源:互联网 发布:gta5娇羞萌妹捏脸数据 编辑:程序博客网 时间:2024/05/18 21:38
linux下c++中如何在主函数中调用其他文件内的函数?
这个作用不巴拉巴拉了,直接上干货!
需要四个文件:a.cpp包含一个被调用的函数,myhead.h预定义这个函数,3.b.cpp主函数,4.Makefile文件。
1.a.cpp
#include "myhead.h"#include <iostream>using namespace std;int myfun(int a,int b){ std::cout<<a+b<<std::endl; return 0;}
2.myhead.h
#ifndef A_H_#define A_H_int myfun(int a,int b);#endif
3.b.cpp
#include "myhead.h"#include <iostream>int main(int argc, char** argv){ int a=2,b=3; myfun(a,b); return 0;}
4.Makefile
CXX=g++Objects=b.o a.omyrun:$(Objects) $(CXX) -o myrun $(Objects)b.o:b.cpp myhead.h $(CXX) -c b.cppa.o:a.cpp myhead.h $(CXX) -c a.cpp
5.linux 命令行下:
make
./myrun
阅读全文
1 0
- 在主函数中调用其他文件内的函数
- c++中如何在主函数中调用其他文件内的函数?
- 如何在某.py文件中调用其他.py内的函数
- 【python】如何在某.py文件中调用其他.py内的函数
- 【python】如何在某.py文件中调用其他.py内的函数
- 【python】如何在某.py文件中调用其他.py内的函数
- keil 中如何调用其他文件的函数
- 在linux中 应用程序如何调用模块内的函数
- 在linux中 应用程序如何调用模块内的函数
- 在linux中应用程序如何调用模块内的函数
- 在linux中 应用程序如何调用模块内的函数
- 在linux中应用程序如何调用模块内的函数
- C中如何调用C++函数、类内函数
- C中如何调用C++函数、类内函数
- C中如何调用C++函数、类内函数
- 在C#中,想调用其他开发环境的DLL内的函数
- 在C++文件中调用C 的函数
- 如何在C++中调用 C 函数?
- parseInt
- leetcode31. Next Permutation
- UDP 客户端编程
- 如何对上司说“不”
- vs2012和Matlab R2014a混合
- c++中如何在主函数中调用其他文件内的函数?
- 在centos7安装SVN
- java按照规则进行字符串的填充
- ora-39002 ora-31694 ora-02354 ora-02368 ora-02369
- UDP 服务器端
- Faster RCNN理解
- Permutations II
- mongodb2.6数据导出导入
- ArrayList删除指定索引数据