c++ 链接

header.h

#ifndef HEADER_H
#define HEADER_H
unsigned long getFac(unsigned short num);
static const unsigned short headerNum = ; #endif // HEADER_H_INCLUDED
this.cpp

#include "header.h"
#include <iostream>
using namespace std; extern unsigned short thatNum; //声明thatNum是来自外部的
static bool printMe = false; int main()
{ unsigned short thisNum = ;
cout << thisNum << "i = " << getFac(thisNum) << endl;
cout << thatNum << "i = " << getFac(thatNum) << endl;
cout << headerNum << "i = " << getFac(headerNum) << endl;
if(printMe)
{
cout << "that.cpp -> printMe = true 发挥作用" << endl;
}
else
{
cout << "this.cpp -> static boolean printMe 发挥作用" << endl;
}
return ;
}
that.cpp
#include "header.h" unsigned short thatNum = ;
bool printMe = true; unsigned long getFac(unsigned short num)
{
unsigned long sum = ;
for (int i=; i<=num; i++)
{
sum *= i;
}
if(printMe)
{
return sum;
}
else
{
return ;
}
}
上一篇:PL/pgSQL学习笔记之八


下一篇:cogs——644. 课程安排问题