每个cpp文件都会被编译吗?
先上代码:
test1.cpp:
#include <iostream>
using namespace std;
int MAX_VALUE = 20;
namespace{
void g_fun(){
cout << "test1.g_fun(): " << MAX_VALUE << endl;
int tmp;
cin >> tmp;
}
}
#include <iostream>
#include "test1.h"
using namespace std;
int main(){
cout << "Main.MAX_VALUE: " << MAX_VALUE << endl;
g_fun();
}
void g_fun(){
cout << "Main.g_fun(): " << MAX_VALUE << endl;
}
#ifndef _TEST1_H_
#define _TEST1_H_
const int MAX_VALUE = 20;
void g_fun();
#endif