devxlogo

Forward-Declaring I/O Classes and Templates

Forward-Declaring I/O Classes and Templates

The standard header contains forward-declarations of the I/O classes and templates. This header is sufficient to refer to any of the I/O classes and templates but not to apply operation to them. For example:

 #include using namespace std;class C{public:  friend ostream& operator

The declaration of the friend function does not need a complete definition of the ostream class; a forward declaration is sufficient in this case. Therefore, is #included instead of the full-blown , which significantly reduces compilation time.

devx-admin

Share the Post: