由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DotNet版 - Can a struct be derived? in C#, in C++
相关主题
新手请教:如何理解generic interface can be an retrun typestatic polymorphism一问
Question about Explicit interface members in c#Factset面经,一面+二面
Question about struct问一个C++ template的问题
问一个Array Sort的问题C++问题几个
C# question最近学了一下 Go
你们最不喜欢.net的什么?can struct be derived from?
同事的这个generic工厂interface让我蛋疼one question about struct
着急求教一個c#問題,怎么能func的時候,subscribe (转载)C++菜鸟问题请教: class versus structure.
相关话题的讨论汇总
话题: struct话题: c#话题: c++话题: derived话题: properties
进入DotNet版参与讨论
1 (共1页)
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

1 (共1页)
进入DotNet版参与讨论
相关主题
C++菜鸟问题请教: class versus structure.C# question
The C++ questions I've been asked你们最不喜欢.net的什么?
不明白C++的一个地方同事的这个generic工厂interface让我蛋疼
one more interview question着急求教一個c#問題,怎么能func的時候,subscribe (转载)
新手请教:如何理解generic interface can be an retrun typestatic polymorphism一问
Question about Explicit interface members in c#Factset面经,一面+二面
Question about struct问一个C++ template的问题
问一个Array Sort的问题C++问题几个
相关话题的讨论汇总
话题: struct话题: c#话题: c++话题: derived话题: properties