consolidate all repos to one for archive
This commit is contained in:
46
semester_2/programiranje_2/primeri/Example29/main.cpp
Normal file
46
semester_2/programiranje_2/primeri/Example29/main.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <iostream>
|
||||
|
||||
class A {
|
||||
protected:
|
||||
int a;
|
||||
public:
|
||||
A() : a(1) {};
|
||||
int get() { return a; }
|
||||
int methodA() { return 100;}
|
||||
};
|
||||
|
||||
class B : protected A {
|
||||
//class B : private A {
|
||||
protected:
|
||||
int b;
|
||||
public:
|
||||
B() : A(), b(2) {};
|
||||
int get() { return b+a; }
|
||||
int methodB() { return methodA() + 200;}
|
||||
};
|
||||
|
||||
class C : private B {
|
||||
protected:
|
||||
int c;
|
||||
public:
|
||||
C() : B(), c(3) {};
|
||||
int get() { return c+b+a; }
|
||||
//int get() { return c+b; }
|
||||
int methodC() { return methodA() + 300;}
|
||||
//int methodC() { return methodB() + 300;}
|
||||
};
|
||||
|
||||
int main() {
|
||||
A a;
|
||||
B b;
|
||||
C c;
|
||||
std::cout << a.get() << std::endl;
|
||||
std::cout << b.get() << std::endl;
|
||||
std::cout << c.get() << std::endl;
|
||||
std::cout << "------------" << std::endl;
|
||||
std::cout << a.methodA() << std::endl;
|
||||
std::cout << b.methodB() << std::endl;
|
||||
std::cout << c.methodC() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user