473,507 Members | 6,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

namespace & typedef problem

br
Hello World!!!

I have the following code

First File (.hpp)
//----------------
namespace A
{
typedef unsigned short ushort

class myClass //definition
}

Second File (.cpp)
//---------------
namespace A
{
class myClass //implementation
}

Third File (.cpp)
//---------------
namespace A
{
string itos(ushort i)
{
//some code
}
}
the problem is that in the third file the ushort isn't recognized
why???
Jan 18 '08 #1
5 6947
On Jan 18, 2:38 pm, "br<dF^n" <vasand...@gmail.comwrote:
Hello World!!!

I have the following code

First File (.hpp)
//----------------
namespace A
{
typedef unsigned short ushort

class myClass //definition

}

Second File (.cpp)
//---------------
namespace A
{
class myClass //implementation

}

Third File (.cpp)
//---------------
namespace A
{
string itos(ushort i)
{
//some code
}

}

the problem is that in the third file the ushort isn't recognized
why???
#include?
Jan 18 '08 #2
br
On 19 Éáí, 00:44, vasyu...@gmail.com wrote:
On Jan 18, 2:38 pm, "br<dF^n" <vasand...@gmail.comwrote:
Hello World!!!
I have the following code
First File (.hpp)
//----------------
namespace A
{
typedef unsigned short ushort
class myClass //definition
}
Second File (.cpp)
//---------------
namespace A
{
class myClass //implementation
}
Third File (.cpp)
//---------------
namespace A
{
string itos(ushort i)
{
//some code
}
}
the problem is that in the third file the ushort isn't recognized
why???

#include?
1) First File "seat.h"
iostream, string

2) Second File (seat.cpp)
"seat.h"

3) Third File (itos.cpp)
iostream, string, sstream
Jan 18 '08 #3
On 2008-01-18 23:38, br<dF^n wrote:
Hello World!!!

I have the following code

First File (.hpp)
//----------------
namespace A
{
typedef unsigned short ushort

class myClass //definition
}

Second File (.cpp)
//---------------
namespace A
{
class myClass //implementation
}

Third File (.cpp)
//---------------
namespace A
{
string itos(ushort i)
{
//some code
}
}
the problem is that in the third file the ushort isn't recognized
why???
Since you have not shown us any of the actual code we can only guess,
but I think it is because you have not included the first file in the
third (it should be included in the second too, if you have not already
done that).

--
Erik Wikström
Jan 18 '08 #4
br<dF^n wrote:
On 19 Éáí, 00:44, vasyu...@gmail.com wrote:
>#include?

1) First File "seat.h"
iostream, string

2) Second File (seat.cpp)
"seat.h"

3) Third File (itos.cpp)
iostream, string, sstream
So there you are, you have answered your own question, no include of
"seat.h".

--
Ian Collins.
Jan 18 '08 #5
br
On 19 Ιαν, 00:52, Erik Wikström <Erik-wikst...@telia.comwrote:
On 2008-01-18 23:38, br<dF^n wrote:
Hello World!!!
I have the following code
First File (.hpp)
//----------------
namespace A
{
typedef unsigned short ushort
class myClass //definition
}
Second File (.cpp)
//---------------
namespace A
{
class myClass //implementation
}
Third File (.cpp)
//---------------
namespace A
{
string itos(ushort i)
{
//some code
}
}
the problem is that in the third file the ushort isn't recognized
why???

Since you have not shown us any of the actual code we can only guess,
but I think it is because you have not included the first file in the
third (it should be included in the second too, if you have not already
done that).

--
Erik Wikström
we are right thank you! i'm a little confused with namespaces and
headers in C++

Jan 18 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
2433
by: Steven T. Hatton | last post by:
In the following code, the only way I can figure out to pass an array of const is by setting the template argument to const in the instanciation expression. It would be (or seem to me) better if I...
2
2891
by: trying_to_learn | last post by:
im in the primary stages of learning C++. The book im learning from says Dont use using namespace.. directive in header file However im trying to make the following header file.I need to include...
10
19219
by: lallous | last post by:
Hello I noticed that when I use #define inside a namespace then this #define only works when prefixed with the namespace name. Is this behaviour standard or just compiler specific? I use...
6
1319
by: Patrick Guio | last post by:
Dear all, I try to compile the following code in two ways: * using one compilation unit: g++ main.cpp base.cpp -o main * creating a library for the class factory. g++ -c -o base.o...
5
5687
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
2
6449
by: yee young han | last post by:
I need a fast data structure and algorithm like below condition. (1) this data structure contain only 10,000 data entry. (2) data structure's one entry is like below typedef struct _DataEntry_...
6
1636
by: SpOiLeR | last post by:
Why doesn't following code compile? Problem line is commented in code. ---------------------- Cut here------------------------------- #include <iostream> #include <list> #include <string> ...
20
3834
by: Patrick Guio | last post by:
Dear all, I have some problem with insertion operator together with namespace. I have a header file foo.h containing declaration of classes, typedefs and insertion operators for the typedefs in...
6
2333
by: bogus1one | last post by:
Hi All Given the following: // NamespaceTemplate.cpp : Defines the entry point for the console application. // #include "stdafx.h"
0
7109
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
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7029
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
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.