using keyword and struct inheritance

#include <iostream>
using std::cout;
using std::endl;

int main() {
    cout << "Hello, World!" << endl;
    return 0;
}

https://medium.com/@computerandgyein/using-keyword-in-c-5d1f64312c3f

https://www.educba.com/c-plus-plus-using/

#include <iostream>
struct demo {
virtual void one(int) { std::cout << "demo::one\n"; }
void two(char)        { std::cout << "demo::two\n"; }
void three(int)         { std::cout << "demo::three\n"; }
protected:
int a;
typedef int val;
};
struct demo1 : demo {
using demo::a;
using demo::val;
using demo::one;
void one(int) { std::cout << "demo1::one\n"; }
using demo::two;
void two(int) { std::cout << "demo1::two\n"; }
using demo::three;
void three(int) { std::cout << "demo1::three\n"; }
};
int main()
{
demo1 i;
demo& d = i;
i.a = 3;
i.one(3);
i.one(3);
i.two(2);
i.two('k');
i.three(3);
i.three(3);
}
posted @ 2024-11-15 11:49  ChrainY  阅读(2)  评论(0编辑  收藏  举报