-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskill_issue.cpp
More file actions
101 lines (86 loc) · 2.32 KB
/
skill_issue.cpp
File metadata and controls
101 lines (86 loc) · 2.32 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include<iostream>
// #include<memory>
// class statement { };
//
// class exprStmt : public statement { };
//
// class Parser {
// public:
// // The return type from func parseExprStmt will get converted to statement which is like child
// // type to base class and here smartpointers up casts to statement type which is implicit
// // so basically implicit up cast happens exprStmt -> statement
// std::unique_ptr<statement> parseExpr() {
// return parseExprStmt();
// }
//
// // This will return the type exprStmt
// std::unique_ptr<exprStmt> parseExprStmt() {
// auto stmt = std::make_unique<exprStmt>();
// return stmt;
// }
//
// };
//
//
//
// class Lexer {
// public:
// std::unique_ptr<Lexer> a;
// char ch;
// public:
// // void call(Lexer* obj) {
// // obj->ch = 'a';
// // }
// };
// checking how enum will work with abstract class
enum class NodeType {
DERIVED,
DERIVED1,
DERIVED2,
};
class abstract {
public:
virtual NodeType mustImplement() const = 0;
};
class derived : public abstract {
public:
NodeType mustImplement() const override {
std::cout << "only derived\n";
return NodeType::DERIVED;
}
};
class derived1 : public abstract {
public:
NodeType mustImplement() const override {
std::cout << "derived1\n";
return NodeType::DERIVED1;
}
};
class derived2 : public abstract {
public:
NodeType mustImplement() const override {
std::cout << "derived2\n";
return NodeType::DERIVED2;
}
};
int main() {
// Lexer lexer;
// lexer.call(&lexer);
int chch = 13;
derived1 p;
p.mustImplement();
abstract* a = &p;
a->mustImplement();
NodeType letSee = a->mustImplement();
switch (letSee) {
case NodeType::DERIVED: std::cout << "okay its only DERIVED\n"; break;
case NodeType::DERIVED1: std::cout << "okay its DERIVED1\n"; break;
case NodeType::DERIVED2: std::cout << "okay its DERIVED2\n"; break;
default: std::cout << "no way we got some issues\n";
};
// std::unique_ptr<Lexer> b;
// // std::unique_ptr<Lexer> a = std::make_unique<Lexer>(ch, std::move(b));
// std::unique_ptr<Lexer> d = std::make_unique<Lexer>(std::move(b), chch);
// std::cout << "ch: " << d->ch << std::endl;
std::cin.get();
}