473,394 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

same name of namespaces in 2 header files.

254 100+
i have this :
Expand|Select|Wrap|Line Numbers
  1. /*ab.h header file*/
  2. ....
  3. ....
  4. namespace Enrol{
  5.      /*bla bla bla inside here*/
  6. };
  7. ...
  8. ...
  9.  
and this:
Expand|Select|Wrap|Line Numbers
  1. /* cd.h */
  2. ...
  3. ...
  4. namespace Enrol{
  5.     /* bla bla bla */
  6. ...
  7. ...
  8. }
  9.  
are they the same "Enrol" ?
or 2 different namespace in 2 header files with the same name only?

Please tell me what's going on with the code i provided above...
thanks seniors!

C++ Beginner,
Nicky Eng.
Dec 10 '06 #1
3 2257
Hi Nicky,

Yes, they are in the same namespace named Enrol, but if you want to use one of them, you have to include the header before!

/jz
Dec 10 '06 #2
nickyeng
254 100+
So, if i want to use both of header files, i included the header in my file here:

Expand|Select|Wrap|Line Numbers
  1. /* trying.cpp */
  2. #include "ab.h"
  3. #include "cd.h"
  4.  
  5. /*
  6.     use the source from that 2 header files using:
  7.      Enrol::xxx
  8.      Enrol::yyy
  9. */
  10.  
  11.  
is it that?
Dec 10 '06 #3
Yes! Sorry for late reply.
You can use the "using" directive as well:

#include "ab.h"
#include "cd.h"

using namespace Enrol;

//then you don't need to specify the namespace for every symbol

xxx();
yyy();

/jz
Dec 14 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: zeroIWantNoSpamtype | last post by:
Hi, I'm trying to get some old programs ported to standard C++ and I don't fancy having to keep typing "std::", so I would like to enter using namespace std (I forget if there's a semicolon,...
6
by: beliavsky | last post by:
If I have a file foo.cpp defining functions f1, f2, f3, etc. and a corresponding header file foo.h, I can #include foo.h in another source file and then use those functions. This gives me access to...
3
by: Johan Nilsson | last post by:
I've seen many alternatives when it comes to referring to types defined in parent/sibling/other namespaces. Consider the following hypothetical namespace layout: namespace company { namespace...
1
by: Srini | last post by:
I was reading the "Exceptional C++" of Herb Sutter. In an example, he mentions the following. // In some library header: namespace N { class C{}; } int operator+(int i, N::C) { return i+1; }...
19
by: Deniz Bahar | last post by:
Hi, I would like to call one of my functions the exact name as an existing C library function (for example K&R2 exercises asks me to make an atof function). If I don't include the header with...
4
by: bnraghu23 | last post by:
Hi all, In a software stack, I have an upper layer & lower layer both from different vendors. The lower layer (is in the form of libraries) exports some functions say for eg:...
5
by: yads12 | last post by:
We have a webservice that is a passthrough to a third party webservice. The third party webservice uses the classes that are named the same for both the submission and result message. We have...
0
by: blat001 | last post by:
Hi, Not 100% sure if this is the correct group to post in but. I have a class that I want to serialize/deserialize to match the MM7 specifications, which I have done but now that we are...
10
by: parag_paul | last post by:
HI all, Suppose I have a huge code base, And I have a very common header file. Now there are mulitple places where this header file is kept. This header file cannot be factored as it has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.