|
|||
mystran wrote: eigentone wrote: Quote: the difference between a c++ struct and a c++ class is that (edit: actually what is the difference?).
default access (class default=private, struct default=public). that's all. One gotcha to be aware of though: if you forward declare something as a class, it must be a class and not a struct. Likewise if you forward declare something as a struct, it must be a struct and not a class. So in some sense they are still "distinct" even if their implementation is the same and you can freely mix them in inheritance chains. while some compilers permit it, and may issue a warning (when visible in the TU). |
|||
| ^ | Joined: 03 Apr 2007 Member: #146135 | ||
|
|||
eigentone wrote: mystran wrote: eigentone wrote: Quote: the difference between a c++ struct and a c++ class is that (edit: actually what is the difference?).
default access (class default=private, struct default=public). that's all. One gotcha to be aware of though: if you forward declare something as a class, it must be a class and not a struct. Likewise if you forward declare something as a struct, it must be a struct and not a class. So in some sense they are still "distinct" even if their implementation is the same and you can freely mix them in inheritance chains. while some compilers permit it, and may issue a warning (when visible in the TU). Yeah, but other compilers fail hard, so you shouldn't really ever do it anyway. |
|||
| ^ | Joined: 11 Feb 2006 Member: #97939 Location: Helsinki, Finland | ||
|
|||
mystran wrote: eigentone wrote: mystran wrote: eigentone wrote: Quote: the difference between a c++ struct and a c++ class is that (edit: actually what is the difference?).
default access (class default=private, struct default=public). that's all. One gotcha to be aware of though: if you forward declare something as a class, it must be a class and not a struct. Likewise if you forward declare something as a struct, it must be a struct and not a class. So in some sense they are still "distinct" even if their implementation is the same and you can freely mix them in inheritance chains. while some compilers permit it, and may issue a warning (when visible in the TU). Yeah, but other compilers fail hard, so you shouldn't really ever do it anyway. agreed. i just use class everywhere, and this problem sprouts up rarely (e.g. when interfacing with different 3rd party distributions). |
|||
| ^ | Joined: 03 Apr 2007 Member: #146135 |
| KVR Forum Index » DSP and Plug-in Development | All times are GMT - 8 Hours |
|
Printable version |
Disclaimer: All communications made available as part of this forum and any opinions, advice, statements, views or other information expressed in this forum are solely provided by, and the responsibility of, the person posting such communication and not of kvraudio.com (unless kvraudio.com is specifically identified as the author of the communication).
Powered by phpBB © phpBB Group
















