![]() |
Difference between including a header file and 'class' declaration in C++
Hello guys,
I am a newbie who is learing C++ and have a simple question. What's the difference between including another header file and putting a 'class' declaration in C++? for example, --------------------------------------------------------------------------------- There are 2 files, a.cpp and b.cpp. Each of these have their own header files, a.h and b.h as well. I want to use class b which is defined in b.h file. case 1: use include like include <b.h> case 2: use class declaration in a.h like class b; --------------------------------------------------------------------------------- What is the major difference in these two statements? |
Hi
Then main difference between forwarding declearion and including or putting class decleration. This is a forwarding declearion Code:
class X;Code:
class XCode:
#include <x.h> (usually x.h is used for class X)But When you use forward deleration you can only instantiate but you cannot use its methods until its complete decleration was seen by the compiler. Cheers, Mohammad Moghimi |
| All times are GMT -5. The time now is 05:33 PM. |