-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStruct.h
51 lines (38 loc) · 911 Bytes
/
Struct.h
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
//
// Created by ki11errabbit on 9/5/22.
//
#ifndef CWITHCLASSES_STRUCT_H
#define CWITHCLASSES_STRUCT_H
#include <string>
#include <vector>
#include <iostream>
#include "Parameter.h"
using namespace std;
class Struct {
private:
string name;
vector<Parameter> body;
public:
Struct(string name, vector<Parameter> body)
: name(name), body(body) {};
Struct(string name)
: name(name) {};
void addBody(Parameter param) {
body.push_back(param);
}
string toString() const{
stringstream out;
out << "struct " << name << " {" << endl;
for (auto var : body) {
out << var << ";" << endl;
}
out << "}";
return out.str();
}
friend std::ostream& operator<<(std::ostream& os, const Struct& strct)
{
os << strct.toString();
return os;
}
};
#endif //CWITHCLASSES_STRUCT_H