Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
20201123
//g++ 7.4.0 // https://kknews.cc/zh-tw/news/n6r9jy8.html #ifndef USEFUL_H #define USEFUL_H #include <iostream> using namespace std; class X { int i; public: X() { i = 0; } void set(int ii) { i = ii; } int read() const { return i; } int permute() { return i = i * 47; } }; #endif // USEFUL_H ///:~ class Y : public X { int i; // Different from X's i public: Y() { i = 0; } int change() { i = permute(); // Different name call return i; } void set(int ii) { i = ii; X::set(ii); // Same-name function call } }; int main() { cout << "sizeof(X) = " << sizeof(X) << endl; cout << "sizeof(Y) = " << sizeof(Y) << endl; Y D; D.change(); // X function interface comes through: D.read(); D.permute(); // Redefined functions hide base versions: D.set(12); } ///:~
run
|
edit
|
history
|
help
0
Patara asoebi
DailyExchRate2
C++ Inheritance Example
stream1
Cuantos
Metodos 2- programa3
How to make stupid to my friend?
Stream generalization
const example
threadpool03