Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 27 Nov 2012
Offline Last Active Private

Posts I've Made

In Topic: Class with static compiler const member variable?

21 October 2014 - 08:32 AM

Got it to work

In Topic: Class with static compiler const member variable?

20 October 2014 - 05:01 AM

How would you recommend I would do it as virtual function? mind giving a example?

I need to know what type the component is, cause depending on the type I need to instantiate another component. Is it possible to somehow upcast with just the base class access? 




not really a problem seeing that IF does what I need, but I just feel like there would be a more proper way to do it. (But I guess dont fix what not broken argument works here)

In Topic: Class with static compiler const member variable?

19 October 2014 - 11:02 PM

The moment I noticed switch didnt work, I just switched to if else statments. But I just cannot rid the problem from my mind for some reason.

In Topic: I have two of the same function and variable value. Which I want to remove at...

04 July 2014 - 03:49 PM

I'm not sure if you want the ID to be the same for all instances of the same class or a unique one for each instance. In Base typeID isn't static but in IBase it is.

Anyway, this is the code that I use to get unique IDs for each class (identical for each instance of the same class) in my event management system. Perhaps you can use it for your purpose.

In this case, IEventBase is the class that need to be used to hold variables of any event type.
To get the unique ID of a specific class you access the member variable (e.g. KeyHitEvent::Type), to get the unique class ID of an IEventBase* you use the virtual member function (e.g. ptr->GetType()).


I forgot to mention it, but I want the ID to be unique across all instances of the class. and yeah your way works wonder, if I just makes my ID public instead of protected, and just have my base be pure virtual. 

Man I feel so stupid, If I just made my id public instead of protected I coulda override the base virtual funtion, I tried to have a static override but the compiler didnt like that. Man I feel so stupid I been at this for the past days. 

In Topic: How to dereference to the derivied class?/How bad is it of my currently way o...

29 May 2014 - 11:39 AM


So many complex word and method!

But will try to improve it from all the feedback!

I think I will go towards Juliean way with the CRTP method, it seems kind of fun. if I make it to work, I will try to improve it with SeanMiddleditch suggestion.


And I will remake my std::map to a std::unordered_map as Servant of the Lord suggested. if I got all the above to work