|
在c++中
class base {
base( char *str ) {
}
...
};
class inherit : public base {
public:
inherit( char *str ) {
...
}
}
int main() {
inherit h("test");
...
}
以上程序编译通不过
Queue.cpp: In constructor `inherit::inherit(char*)':
Queue.cpp:14: error: no matching function for call to `base::base()'
Queue.cpp:6: note: candidates are: base::base(const base&)
Queue.cpp:8: note: base::base(char*)
(在从上到下的构造函数调用中基类部分必须要调用????)
而在c#中
public class base {
public base( string str ) {
}
...
}
public class inherit : base {
public inherit( string str ) {
}
...
}
class startup {
static void main() {
inherit h = new ( "test" );
}
}
一切正常 |
|