Jump to content
  • Advertisement
Sign in to follow this  
Erzengeldeslichtes

VC2005 b2, Managed C++, Global managed class?

This topic is 4843 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'm somewhat new to managed C++, but I've been figuring it out relitively well, figuring out how to make the darn thing work on my own, even when there are times when I want to do one thing (like initialize a value on the gcheap) I can at least figure out a workaround (create on gcheap, then assign). However, I can't figure out a workaround for this. What I want to do is:
ref class MyClass
{
public:
MyClass(int i);
};
const MyClass Hiall(1);
void Func()
{
  Use(Hiall);
}


But the compiler complains of "Global or static variable may not have managed type." The only way to make it work is:
ref class Globals
{
static const MyClass Hiall = MyClass(1);
};
void Func()
{
  Use(Globals::Hiall);
}


However, I have no way of extending the "Globals" class without going in and editing it directly (so I can't have "Globals" in "Party.h" and "Globals" in "Objects_Base.h", and making a specially named one is really unweildy). I also have to specify the class first. That actually defeats the entire purpose of the globals I'm using. Is there any way to get past this restriction on managed C++? "using namespace Globals" or "using ref class Globals" doesn't work. I can't typedef it. The best I can think of is macro it, and that just seems like a few thousand steps backward for this scenario.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!