Since a struct is virtually identical to a class in C++, it is legal to inherit from a struct just as you would from a class. That doesn't mean its always good idea as a design decision, but it is definitely legal.
In your example, the colon is on the wrong side of the public keyword. I assume that's just a typo.
Thank you very much by these answers, and thanks for the observation about the wrong side of the colon uolj, I just have not found the way to correct this post, is there some way?. Ion Filipski thanks for you reply, in your example you inherit from a class and that is one of the advantages of the OOP, but I am not very sure to use the inheritance from a struct, but he is really useful,
OK, in conclusion is legal while the compiler does not protest, but probably isn't a very orthodox metod of programming, at least that is what i think because is not a very used method; Although in C it is the only way to create more sophisticated data types, isn't it.
Since you would know what is WNDCLASS structure and you have used it a lot, you will find much manu advantages than you see now. So, it is a standard method of using inheritance.
> probably isn't a very orthodox metod of programming, at least that is what i think because is not a very used method
I'm not sure what you mean by that. As was mentioned earlier, a struct is essentially exactly the same as a class, the only difference lying in default access priveleges.
Since inheriting from a class is an orthodox method of programming, inheriting from a struct is, as well. It might not be stylistically used much, with struct often being reserved for simple types with all public members and therefore not prime candidates for being parent classes.
> Although in C it is the only way to create more sophisticated data types, isn't it.
No, especially since inheritance doesn't exist in C, only in C++.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.