您的位置:首页 > 编程语言 > C语言/C++

c++ 的 坑真多之头文件

2016-05-15 14:41 441 查看
我发现类在做参数时,是可以不引用头文件,即不用#include"xxx.h"的,比如下面这样是没有问题的

#pragma once
#include <string>
#include <iostream>

class Humankind;
class Person {
public:
Person();
void sayHello(Humankind human);
};


但如果这个类是用来被继承,就编译不过,必须写头文件包含,即这样:

#pragma once
#include <string>
#include <iostream>
#include "Humankind.h"
class Person : Humankind{
public:
Person();
void sayHello();
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: