If class B uses only pointers or references of class A, you don’t have to include A.h. You can simply forward declare class A as shown below.
//File B.hclass A; //forward Decalarationclass B{ A * ptrA; .. //other members};
Home » Use Forward Declarations to Speed Up Compiling
If class B uses only pointers or references of class A, you don’t have to include A.h. You can simply forward declare class A as shown below.
//File B.hclass A; //forward Decalarationclass B{ A * ptrA; .. //other members};
At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.
See our full editorial policy.