Making C++ Classes inherit from C Structs, Recommended?

Viewed 2159

I was recently doing some Windows Api coding (still doing it). And I was trying to find the best way to wrap the WNDCLASSEX into a C++ class, when I had this crazy idea, the WNDCLASSEX is a struct right? (even though it is written in c) and in C++ structs are treated as classes, so why don't I declare my WinCLass as a derivative of WNDCLASSEX , so I tried:

 class WinClass : protected WNDCLASSEX

And it worked! Then I tried using it with SDL structs but those worked too. But some structs(especially SDL ones) either don't compile or cause unexplained runtime errors when I derive classes from them. So my question: Is this kind of C struct use recommended? Is it actually used by pros, or is it just a lame hack? Should I use for my wrapppers or apps, or will this just introduce unexplained bugs?

3 Answers
Related