标签:style blog color io os div sp 问题 c
这个问题会引起莫名其妙的编译错误,
碰到类里有其他类的指针的话,不要#include,提前声明下即可
class_a.h
#ifndef CLASS_A_H #define CLASS_A_H class B; class A { public: void Print() { std::cout << "This is class A\n"; } B *b; }; #endif
class_b.h
#ifndef CLASS_B_H #define CLASS_B_H class A; class B { public: void Print() { std::cout << "This is class B\n"; } A *a; }; #endif
main.cpp
#include <iostream> #include "class_a.h" #include "class_b.h" int main() { A aa; aa.b->Print(); B bb; bb.a->Print(); }
标签:style blog color io os div sp 问题 c
原文地址:http://www.cnblogs.com/as3lib/p/3986731.html