Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
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
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create struct containing variable array struct shoeyfighter C 14 Nov 6th, 2006 4:26 AM
Casting a struct to s aimilar struct shoeyfighter C 6 Oct 27th, 2006 3:59 PM
Appreciate comments on some linked list code Jessehk C 5 Jul 20th, 2006 8:59 PM
struct program skipping inputs codylee270 C 7 Dec 5th, 2005 8:02 AM
c struct : problems whit structs containing each other mevuorin C 10 Jul 7th, 2005 2:05 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:33 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC