C ++中的MakeFile及其应用
在本教程中,我们将讨论一个程序,以了解C++及其应用程序中的MakeFile。
任务是使用MakeFile破坏整个程序。通常,通过使.cpp文件和.h文件具有所有类/功能并将它们链接在一起来完成。
示例
main.cpp
#include <bits/stdc++.h>
#include "function.h"
using namespace std;
//主执行程序
int main(){
int num1 = 1;
int num2 = 2;
cout << multiply(num1, num2) << endl;
int num3 = 5;
cout << factorial(num3) << endl;
print();
}print.cpp
#include <bits/stdc++.h>
#include "function.h"
using namespace std;
void print(){
cout < "makefile" << endl;
}析因
#include <bits/stdc++.h>
#include "function.h"
using namespace std;
//析因程序
int factorial(int n){
if (n == 1)
return 1;
return n * factorial(n - 1);
}cpp
#include <bits/stdc++.h>
#include "function.h"
using namespace std;
int multiply(int a, int b){
return a * b;
}功能.h
#ifndef FUNCTIONS_H #define FUNCTIONS_H void print(); int factorial(int); int multiply(int, int); #endif
输出结果
2 120 makefile
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短