Archived

This topic is now archived and is closed to further replies.

Global variables from within functions

This topic is 5827 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I there a way to declare global variables from within functions in C++ (or C for that matter)?
It is foolish for a wise man to be silent, but wise for a fool. Matthew WebMaster www.Matt-Land.com All your Xbox base are belong to Nintendo.

Share this post


Link to post
Share on other sites
No, but why would you want to? Well anyway, static variables in functions act like globals, except they can only be accessed within that one function.

~CGameProgrammer( );

Share this post


Link to post
Share on other sites
I would want to so that I could declare a variable or class at one point in the program then have it be accessable by other functions. That way my global classes are not intilized right away, and can you overload constructor functions?


It is foolish for a wise man to be silent, but wise for a fool.

Matthew
WebMaster
www.Matt-Land.com

All your Xbox base are belong to Nintendo.

Share this post


Link to post
Share on other sites