Tekkaman

导航

 

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");
}

  

posted on 2013-08-13 16:11  Tekkaman  阅读(310)  评论(0编辑  收藏  举报