Blue Theme Orange Theme Green Theme Red Theme
 
Team Foundation Server Hosting
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
Search :       Advanced Search »
Home » Blogs Home » Blog Detail

Header file inclusion techniques

 by Sivaraman Dhamodaran on Dec 13, 2011

In this blog we will see two different techniques of including the header files
Comments: 0 Views: 758 Printable Version 

1. Introduction

 

Header files usually have the declarations required by the definitions. Say for example a class template and its layout is specified in the header file. This layout will just have variable and function names with their scopes. The implementation file actually makes use of the variables and links them with the function implementation.

 

2. Including the header file

 

Header files are referred by the implementation files by using the #include pre-processor directive. The file name extension for the header file is .h and some old C style programmer uses .hpp also.  The implementation file with an extension .cpp refers these header files to know the declarations.  So if we have some common declarations required for more than one implementation groups, we do refer the same header file for both the implementation files.

 

You can include the header file in two different ways.

1) Using the <>

2) Using the “”

 

Below are the examples for it:

 

#include "stdafx.h"

#include <conio.h>

 

In the below section we will see the difference.

 

3. Two types of inclusion

 

The header file specified in between the angle braces <> tells that the header file is part of the c++ libraries. The preprocessor will search for the file first in the IDE specific paths and then in the path specified path the compiler switch /I. This is shown below:

 

Pic01.JPG

 

The project property shows where you can set this /I option.

 

OK. What about the other option, which is using the header between double quotes? In that case the compiler will search for the current directory of the file that has the #include statement. When the referred header file is not found, then it searches the file like it did for the <> braces.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
 
What do you say about this post? Post a comment here
*Title:
*Comment:
 
Comments not available.
Team Foundation Server Hosting
Become a Sponsor

 Blogger's Profile
Age: Not Available
Location:
Title: Systems Engineer
Joined: Oct 21, 2010
Education: Masters Degree
 More Blogs from this Blogger
[Video] OnClose Handler
[Video] Storing and Loading the Window and Toolbar position
Swapping Exe Process
How Exe file is Generated by VS2005 C++ Project?
What is Exe
Header files: Multiple Inclusion problem - Solution B
Header files: Multiple Inclusion problem - Solution A
Header files: Multiple Inclusion problem - Reason
Header files: Multiple Inclusion problem
Header file inclusion techniques
View all »
 Latest Blogs
[Video] OnClose Handler
[Video] Storing and Loading the Window and Toolbar position
The Euclidean Algorithm
Swapping Exe Process
How Exe file is Generated by VS2005 C++ Project?
What is Exe
Header files: Multiple Inclusion problem - Solution B
Header files: Multiple Inclusion problem - Solution A
Header files: Multiple Inclusion problem - Reason
Header files: Multiple Inclusion problem
View all »
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 
6 Months Free & No Setup Fees ASP.NET Hosting!
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.