Blue Theme Orange Theme Green Theme Red Theme
 
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 files: Multiple Inclusion problem - Reason

 by Sivaraman Dhamodaran on Jan 10, 2012

In the previous Blog I talked about the error that you receive because of the more than one time inclusion of the same header file. In this blog we will look at the reason.
Comments: 0 Views: 753 Printable Version 
For continuation you can look at the Previous Blog: Link

As I already told, #include is the pre-processor directive, and the compiler will replace the content of header file before processing the cpptest.cpp. When it does, the file looks like as shown below (I am skipping the stdafx.h, conio.h):

int Add_Numbers(int, int);

int Mult_Numbers(int, int);

 

int Add_Numbers(int a, int b)

{

            return (a + b);

}

 

int Mult_Numbers(int a, int b)

{

            return (a * b);

}

 

int Add_Numbers(int, int);

int Mult_Numbers(int, int);

 

int Add_Numbers(int a, int b)

{

            return (a + b);

}

 

int Mult_Numbers(int a, int b)

{

            return (a * b);

}

 

int Add_three_numbers(int, int, int);

 

int Add_three_numbers(int a, int b, int c)

{

            return ( Add_Numbers(a, b) * c );

}

int _tmain(int argc, _TCHAR* argv[])

{

 

            return 0;

}

The first set of code in red color is the content of simplemath.h

The second set of code in Green Normal font style is also the content of simplemath.h (Note that extendedmath.h includes the simplemath.h)

The stuff is green bold is actual content of the extendedmath.h

The final Red bold text is original content of the CPP file.

Now once all the #include statements are replaced, the compiler will check & return an error. Now, I no need to explain that error, as you can understand it yourself.
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.
6 Months Free & No Setup Fees ASP.NET 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.