Wrox Programmer Forums
|
BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2008 by Ivor Horton; ISBN: 9780470225905
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 12th, 2009, 04:42 PM
Registered User
 
Join Date: Jun 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default A Vital Concept: PLSSS HELP!!!

What is the link between a namespace and a header file? I mean how do namespaces and header file act together? Does the namespace contain the function definitions or the header files...Pls elaborate. I have read a lot about this , but have not got any answer. I will be grateful to you....Hally
 
Old July 7th, 2009, 05:07 PM
Registered User
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default About Namespaces and Header Files

I'll keep this short and sweet.
Namespace

"A namespace is a mechanism in C++ for avoiding problems
that can arise when duplicate names are used in a program for different things, and it does this
by associating a given set of names such as those from the standard library with a sort of family name,
which is the namespace name." (Horton Beginning Visual C++ 2008 p43)

Header file
The <iostream> file is
called a header file because it’s usually brought in at the beginning of a program file. The <iostream>
header file contains definitions that are necessary for you to be able to use C++ input and output statements.(Horton Beginning Visual C++ 2008 p43)

so for example let's say you wanted to use the command cout.
If you don't have a namespace declared then you have to fully qualify the name so: std::cout
This shows that cout resides within the namespace std. If you don't want to have to type the fully qualified name every time you use it then you have two options.
1. a using declaration ex. using std::cout;
or
2. a using definition ex using namespace std;

Summary: Header files contain function definitions, etc
Namespaces help to prevent confusing in case variables have the same name.





Similar Threads
Thread Thread Starter Forum Replies Last Post
XMail Concept (Help) gmbalaa General .NET 1 August 26th, 2007 01:57 PM
shopping cart concept sarah lee ASP.NET 1.0 and 1.1 Basics 1 October 16th, 2006 12:29 PM
Design Concept shazza Biztalk 1 August 23rd, 2006 09:54 AM
Concept of VB.net johnsonlim026 General .NET 1 July 10th, 2006 05:43 AM
Is there "Floating ToolBar" concept in C# ? kishore_peddi C# 1 April 15th, 2004 01:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.