c++ 的 坑真多之头文件

我发现类在做参数时,是可以不引用头文件,即不用#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();
};
原文地址:https://www.cnblogs.com/heben/p/5495210.html