namespace & typedef problem

B

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???
 
V

vasyutin

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?
 
E

Erik Wikström

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).
 
I

Ian Collins

br<dF^n said:
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".
 
B

br

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).

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top