Home - Watched Topics - FAQ - Member List - Groups - Edit Profile - Search - Slot Machine - Drawing - Play Flash Games
Login or Click Here to Register
Username:    Password:      Log me on automatically each visit    
 Log in to check your private messages  -  Log in
Forward Declarations and Templates
 
Post new topic   Reply to topic    Heroes of Gaming Forum Index -> General Discussion -> Programming
Author Message
Clint
Newbie
Newbie


Joined: 11 Jan 2008
Posts: 3


48.28 Bronze Chips
0.00 Silver Chips
0.00 Gold Chips

PostPosted: Fri Jan 11, 2008 6:23 am    Post subject: Forward Declarations and Templates Reply with quote

It is illegal to use forward declarations with typedef names, as in:

class string;
void f(string& s); //illegal, string is a typedef name
Even a typename won't do here:

typename std::string; //still illegal
void f(std::string& s);
The problem with these forward declarations is that std::string is not a class, but a typedef name defined like this:

typedef basic_string<char, char_traits<char>, allocator<char> >string;
In order to generate the correct mangled name for the function f, the compiler has to see the non-typedef'd form of its argument. In other words, there is no escape from #including the header <string> in this case.
Back to top
sahara1
Newbie
Newbie


Joined: 10 Jan 2010
Posts: 1


4.74 Bronze Chips
0.00 Silver Chips
0.00 Gold Chips

PostPosted: Sun Jan 10, 2010 12:16 pm    Post subject: Reply with quote

I dont think this construction falls under splitting the declaration and definition of a template file since this does not require the export keyword in VC++ and since this is only a prototype. I'm basing this off of VC++'s support but it sounds like this is a bug in g++.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Heroes of Gaming Forum Index -> Programming All times are GMT - 8 Hours
Page 1 of 1

 



HeroesOfGaming.com | Cheat Codes | Shop | Calendar | Forum RPG | Flash Arcade Games | Bets

web counter   © 2005-2006 HeroesOfGaming.com / Powered by phpBB © 2001, 2005 phpBB Group / RSS Feed RSS Site Feed


Help Us Grow!