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
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短