|
|
@ -3,11 +3,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
class mybase {
|
|
|
|
class mybase {
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
|
|
std::string ids;
|
|
|
|
std::string ids;
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
mybase(std::string ids)
|
|
|
|
mybase(std::string ids)
|
|
|
|
: ids(ids) {}
|
|
|
|
: ids(ids) {}
|
|
|
|
|
|
|
|
|
|
|
@ -17,16 +15,13 @@ class mybase {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class myclass : public mybase {
|
|
|
|
class myclass : public mybase {
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
myclass(std::string ids)
|
|
|
|
myclass(std::string ids)
|
|
|
|
: mybase(ids) {}
|
|
|
|
: mybase(ids) {}
|
|
|
|
|
|
|
|
|
|
|
|
void foo() {
|
|
|
|
void foo() {
|
|
|
|
std::cout << "i'm a myclass! ids: " << ids << std::endl;
|
|
|
|
std::cout << "i'm a myclass! ids: " << ids << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void nocast(myclass* x) {
|
|
|
|
void nocast(myclass* x) {
|
|
|
@ -40,8 +35,8 @@ void ccast(void* x) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void staticcast(void* x) {
|
|
|
|
void staticcast(void* x) {
|
|
|
|
// C++ static_cast. When I *know* it's myclass*, and want to revert an implicit
|
|
|
|
// C++ static_cast. When I *know* it's myclass*, and want to revert an
|
|
|
|
// conversion.
|
|
|
|
// implicit conversion.
|
|
|
|
myclass* foo = static_cast<myclass*>(x);
|
|
|
|
myclass* foo = static_cast<myclass*>(x);
|
|
|
|
foo->foo();
|
|
|
|
foo->foo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|