B
blueblueblue2005
Hi, there was a post several days ago about using forward class
declaration to solve the circular including issue, today, one question
suddenly came into mind: which class should the forward class
declaration statement be in? suppose I have a class A and B, sample
code as following:
// A.h
#ifndef A_H
#define A_H
class B; // forward declaration
// define A here
#endif
// B.h
#ifndef B_H
#define B_H
#include B.h
// define B here
#endif
from the ListNode and List example in Deital book, I found if A is part
of B, say,ListNode is part of List, then the forward declaration
statement is in A. Is this the general rule? or we can randomly put the
forward declaration stmt in either class, and let the other to use the
#include ???
declaration to solve the circular including issue, today, one question
suddenly came into mind: which class should the forward class
declaration statement be in? suppose I have a class A and B, sample
code as following:
// A.h
#ifndef A_H
#define A_H
class B; // forward declaration
// define A here
#endif
// B.h
#ifndef B_H
#define B_H
#include B.h
// define B here
#endif
from the ListNode and List example in Deital book, I found if A is part
of B, say,ListNode is part of List, then the forward declaration
statement is in A. Is this the general rule? or we can randomly put the
forward declaration stmt in either class, and let the other to use the
#include ???