⒈ 头文件引用
⒉ extern调用同一个项目中的其他cpp文件中的函数
▶【 main.cpp 】
#include"day0915_3.h"
extern void func_1();
void func_2(){
cout << "Hello" << endl;
}
int main(){
// void (*x)();
// x = func_1;
// x();
int a = 99;
int *p = &a;
cout << *p**p <<endl;
cout << func_h() << endl;
system("pause");
func_1();
return 0;
}
▶【 day0915_3.h 】
#ifndef 条件编译,防止头文件被多次包含
#ifndef __DAY0915_3_H__
#define __DAY0915_3_H__
#include"iostream"
using namespace std;
int func_h();
#endif
▶【 day0915_3.cpp 】
#include <iostream>
using namespace std;
int func_h(){
return 999;
}
void func_1(){
cout << "hello,world!" << endl;
}