Sign in to follow this  

static and normal class

This topic is 3584 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
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

This topic is 3584 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this