View Single Post
Old Dec 27th, 2006, 9:11 AM   #1
Klarre
Game engine designer
 
Klarre's Avatar
 
Join Date: May 2005
Location: Sweden
Posts: 312
Rep Power: 4 Klarre is on a distinguished road
namespace vs struct

Usually when I want global functions in my C++ applications I do like this:
namespace Tool
{
	static inline int foo() {}
	static inline int bar() {}
}

int main()
{
	Tool::foo();
	Tool::bar();
}

Another more common way to achieve this result is by doing it this way:
struct Tool
{
	static inline int foo() {}
	static inline int bar() {}
};

int main()
{
	Tool::foo();
	Tool::bar();
}

So to my question: Is there a difference between them (have not checked the generated code yet)? Which one should I prefer and why?
Thanks for your thoughts!

/Klarre
__________________
http://www.klarre.se
Klarre is offline   Reply With Quote