-
Notifications
You must be signed in to change notification settings - Fork 1
/
Virtual01Basic.cpp
45 lines (37 loc) · 967 Bytes
/
Virtual01Basic.cpp
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
38
39
40
41
42
43
44
45
/*
* =====================================================================================
*
* Filename: Virtual01Basic.cpp
*
* Description: Basic example of Virtual
*
* Created: 26/07/2020
*
* Author: Maikol Guzmán mike@guzmanalan.com
* Organization: Universidad Nacional de Costa Rica
*
* =====================================================================================
*/
#include <iostream> // allows program to output data to the screen
struct Base {
virtual int get() const {
return 4;
}
/*int get() const {
return 4;
}*/
};
struct Derived : Base {
int get() const {
return 1;
}
};
int get(const Base &b) {
return b.get();
}
// function main begins program execution
int main(int argc, const char *argv[]) {
std::cout << "Welcome to the UNA! (VIRTUAL)" << std::endl; // display message
Derived derived;
return get(derived);
} // end function main