A very basic question
-
Here is a basic question on Structures. Do Structures support inheritance and if so how different is it from Class inheritance?
--- :beer: Hakuna-Matata :beer: It means no worries for the rest of your days... It's our problem free, Philosophy :jig: "I think my response was 'What idiot dreamed this up?'" -- Mary Ann Davidson, Oracle's chief security officer, in typical blunt manner, remembering her reaction to the company's scheme to brand its databases as "unbreakable."
-
Here is a basic question on Structures. Do Structures support inheritance and if so how different is it from Class inheritance?
--- :beer: Hakuna-Matata :beer: It means no worries for the rest of your days... It's our problem free, Philosophy :jig: "I think my response was 'What idiot dreamed this up?'" -- Mary Ann Davidson, Oracle's chief security officer, in typical blunt manner, remembering her reaction to the company's scheme to brand its databases as "unbreakable."
Yes, structures do support inheritance in C++. If I remeber correctly the only difference now remaining between structures and classes is that structure members are
public
by default as opposed toprotected
. I generally use a struct by convention when the object I'm creating is data only, ie. it has no functions beyond possibly constructors. Occasionally I might use a struct with functions if I'm creating a type that's intended to behave like a built in type or a special translation type but that is a whole different tricky kettle of fish :)Nothing is exactly what it seems but everything with seems can be unpicked.
-
Here is a basic question on Structures. Do Structures support inheritance and if so how different is it from Class inheritance?
--- :beer: Hakuna-Matata :beer: It means no worries for the rest of your days... It's our problem free, Philosophy :jig: "I think my response was 'What idiot dreamed this up?'" -- Mary Ann Davidson, Oracle's chief security officer, in typical blunt manner, remembering her reaction to the company's scheme to brand its databases as "unbreakable."
Generally a struct is for data only, and yes they can be inherited. You will sometimes see structs derived from the built in windows types. It's not often you will see member functions within a struct, though sometimes the need does arrise, especialy when overiding the comparison operators. Other than that, a structs members are public by default, whereas a class's members are protected.
-
Here is a basic question on Structures. Do Structures support inheritance and if so how different is it from Class inheritance?
--- :beer: Hakuna-Matata :beer: It means no worries for the rest of your days... It's our problem free, Philosophy :jig: "I think my response was 'What idiot dreamed this up?'" -- Mary Ann Davidson, Oracle's chief security officer, in typical blunt manner, remembering her reaction to the company's scheme to brand its databases as "unbreakable."
Yes its possible on the C++ and C++.Net different is about access level also I think you need to see again about classes and structs so you will be see differences classes and structs.;)