f******l 发帖数: 26 | 1 can you say:
strcut A {
...
}
struct B : A {
...
} | k****i 发帖数: 1072 | 2 I don't think so
【在 f******l 的大作中提到】 : can you say: : strcut A { : ... : } : struct B : A { : ... : }
| p***n 发帖数: 635 | 3 in C++, yes, a struct can inherit from another. actually in C++ world, the only
difference btw a struct and a class is that the default access modifiers for
methods are different. for class: private for struct:public
in C#, it is a different story, structs cannot inherit from other structs
however, they can derive from interfaces. it is quite different from class
in C#.
【在 k****i 的大作中提到】 : I don't think so
| a*******t 发帖数: 891 | 4 Could somebody provide some sample code on how this is done?
if have a list of items, and every item has some common properties (same as
the original question). Is there a way so I can access each item's properties
with something like item[i].properties ?
only
【在 p***n 的大作中提到】 : in C++, yes, a struct can inherit from another. actually in C++ world, the only : difference btw a struct and a class is that the default access modifiers for : methods are different. for class: private for struct:public : in C#, it is a different story, structs cannot inherit from other structs : however, they can derive from interfaces. it is quite different from class : in C#.
| d******p 发帖数: 24 | 5 While a struct cannot inherit from another struct, it
can extend a interface. Try to define an interface
for those common properties;
【在 a*******t 的大作中提到】 : Could somebody provide some sample code on how this is done? : if have a list of items, and every item has some common properties (same as : the original question). Is there a way so I can access each item's properties : with something like item[i].properties ? : : only
|
|