Header File Dependencies

Header File Dependencies

  什么时候可以用前置声明替代include?

  1、当 declare/define pointer&reference 时。 

  2、当 declare static data member 时。

  3、当 declare function 时。

    So,下面这段代码会被正常编译通过:

#include <stdio.h>

class Point;

struct Square
{
    Point *pt;
    Point &ref;
    static Point point;
};

void xshow(Point p); 

void show()
{
    printf("Hello world");
}

  

原文地址:https://www.cnblogs.com/tekkaman/p/3255329.html