#include"../../include/add/add.h"intCalAdd(int a,int b){int tmp1 = a /2;if(b %2==1){
b = b *2+3;}else{
b = b +5;}int tmp2 =-1;
tmp1 = a + tmp1 + b + tmp2;return tmp1;}floatCalAdd(float a,float b,float c){float tmp1 = a - b;for(int i =0; i <10; i ++){float tmp2 = i *0.5;
tmp1 += tmp2;}float tmp2 = a + c - b - tmp1;return tmp2;}
subtract.cpp:
#include"../../include/subtract/subtract.h"intCalSubtract(int a,int b){int tmp1 =5;while(tmp1){int tmp2 =100;
a += tmp2 /2;-- tmp1;}int tmp3 = a - b;return tmp3;}floatCalSubtract(float a,float b){float tmp1 =-111;for(int i =0; i <100; i ++){float tmp2 =-199;
a -= b;
a += tmp2;}float tmp3 = a - b;return tmp3;}
test.cpp:
#include<iostream>;#include<stdlib.h>;#include"../../include/add/add.h"#include"../../include/subtract/subtract.h"
using namespace std;intmain(int argc,char* argv[]){
cout<<"integer test, input integer:"<<endl;int a =5, b =10;if(argc >1)
a =atoi(argv[1]);if(argc >2)
b =atoi(argv[2]);int ret =0;
cout<<"start add:"<<endl;
ret =CalAdd(a, b);
cout<<"integer add :"<<ret<<endl;
cout<<"start subtract:"<<endl;
ret =CalSubtract(b, a);
cout<<"integer subtract:"<<ret<<endl;
cout<<"ok!!"<<endl;return0;}
打开终端,定位为到/demo/test/目录下,依次输入:
g++-c -g test.cpp ../../src/add/add.cpp ../../src/subtract/subtract.cpp
g++-o test test.o add.o subtract.o