Jump to content
  • Advertisement
Sign in to follow this  
AcidZombie24

static and normal class

This topic is 3956 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 have a windows defined struct. I will also have a Linux define struct and i want to access it members with a generic class. instead of doing struct_t var; className::funcName(&var); i want to do someClass<className, struct_t> var; var.funcName(); It would make things much easier, is there a way for me to do this?

Share this post


Link to post
Share on other sites
Advertisement
Maybe I'm misunderstanding your problem but...
It sounds like you should create a generic super-class with a few common virtual functions which your derived Linux and Windows classes would then override.
From there you'd use some kind of Factory I guess to return a pointer to the 'generic-super' class (which is a cast of the specific Windows/Linux class).
Make sense?

Share this post


Link to post
Share on other sites
Quote:
Original post by AcidZombie24
i have a windows defined struct. I will also have a Linux define struct and i want to access it members with a generic class.

instead of doing struct_t var; className::funcName(&var); i want to do someClass<className, struct_t> var; var.funcName();

It would make things much easier, is there a way for me to do this?


Sorry, I can't at all figure out what you are trying to do. What do you even mean by "a windows/linux defined struct"? Please show more of the existing code.

Consider that the program will need to be recompiled separately for both platforms anyway. There is no such thing as being "runtime cross-platform". There must be two separate executables (because one built for Windows cannot run on Linux and vice versa, full stop), and the Windows executable will never have to deal with a Linux-specific structure (and vice-versa) because the fact that it's a Windows executable directly implies that it's running on Windows.

Unless, of course, you are trying to make a program that runs on Windows, but prepares some data for another program that runs on Linux?

Share this post


Link to post
Share on other sites
I assume he's just trying to separate some linux and windows specific code. And I think basically what he's asking is how to make a wrapper so that his main program doesn't need to directly reference any OS-specific stuff... much like a lot of graphics engines wrap DirectX/OpenGL into a common interface.
Hehehe, but this is all assumptions... maybe he meant something totally different! :P

Share this post


Link to post
Share on other sites
Right, well... the whole point is, trying to address that issue at run-time (which is what polymorphism does) is pointless: it's too late at that point.

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!