![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2006
Posts: 36
Rep Power: 0
![]() |
namespace alias?
How to use it correctly?
I have a header where I put namespace out {
class in { /* code */ };
}Now how do I make "namespace alias" in cpp file? Trying: namespace new = out::in; doesn't work... Error: expected namespace-name before ';' token unknown namespace `<declaration error> 'new' has not been declared cc: gcc 3.4.2 os: windows 2000 Thanks PS: Code compiles when I type full namespace names ... |
|
|
|
|
|
#2 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 644
Rep Power: 4
![]() |
I think it's:
namespace new = out; As it stands, it looks like your are trying to make a namespace an alias for a class.
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
#3 |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 301
Rep Power: 4
![]() |
You use the namespaces like this:
namespace out
{
class in {};
}
int main()
{
out::in* instance = new out::in;
}
__________________
http://www.klarre.se |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2006
Posts: 36
Rep Power: 0
![]() |
Ok, thanks... I understand now...
|
|
|
|
|
|
#5 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 644
Rep Power: 4
![]() |
He is not trying to make an instance of a class (at least, I don't think he is).
He's trying to make an alias for a namespace. EDIT: I was just proven wrong. :p Why did you say "alias" then, iradic?
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
#6 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
In any case, you don't use 'new' as if it's a variable for assignment, it's a keyword.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#7 |
|
Programmer
Join Date: Feb 2006
Posts: 36
Rep Power: 0
![]() |
Confusion all over the place...
![]() Jessehk correctly read my mind... Thanks again bye.. PS: I will edit original post. |
|
|
|
|
|
#8 |
|
Programmer
Join Date: Feb 2006
Posts: 36
Rep Power: 0
![]() |
Edit doesn't show in my first post?
|
|
|
|
|
|
#9 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
You can't edit after 30 minutes. Regarding editing, it's better if you ADD or EXPLAIN things in a edit (other than typos, of course), after responses have been received, so that the original meaning of the thread doesn't go south.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| .NET Socket Class | hbe02 | Show Off Your Open Source Projects | 1 | Oct 7th, 2006 11:00 AM |
| import namespace | hush | Visual Basic .NET | 3 | Aug 24th, 2006 5:40 PM |
| C++ template and namespace question | Soulstorm | C++ | 3 | Jan 22nd, 2006 2:46 PM |
| Regarding namespace | aniruddha_dhondge | C++ | 22 | Sep 29th, 2005 7:38 PM |
| C++ namespace question | kevin_cpp | C++ | 1 | May 17th, 2005 3:28 PM |