首页 > 编程语言 > 详细

c++ 的 坑真多之头文件

时间:2016-05-15 15:12:24      阅读:246      评论:0      收藏:0      [点我收藏+]

我发现类在做参数时,是可以不引用头文件,即不用#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();
};

 

c++ 的 坑真多之头文件

原文:http://www.cnblogs.com/heben/p/5495210.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!