forked from chihyang/CPP_Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExer18_26.cpp
More file actions
37 lines (37 loc) · 713 Bytes
/
Copy pathExer18_26.cpp
File metadata and controls
37 lines (37 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <string>
#include <vector>
struct Base1 {
void print(int) const {} // public by default
protected:
int ival;
double dval;
char cval;
private:
int *id;
};
struct Base2 {
void print(double) const; // public by default
protected:
float fval;
private:
double dval;
};
struct Derived : public Base1 {
void print(std::string) const; // public by default
protected:
std::string sval;
double dval;
};
struct MI : public Derived, public Base2 {
void print(std::vector<double>) const; // public by default
void print(int i) { Base1::print(i); }
protected:
int *ival;
std::vector<double> dvec;
};
int main()
{
MI mi;
mi.print(42);
return 0;
}