Skip to content

Commit 0884e69

Browse files
committed
Change for c++98
1 parent 2df8bbe commit 0884e69

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

School.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include <cstdlib>
1111
#include <ctime>
1212

13+
// Include only for convert int to string
14+
#include <sstream>
15+
1316

1417
using namespace std;
1518

main.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ int main(int argc, char* argv[]) {
3131
for (int i=0 ; i<size_stud ; i++) {
3232
if (i % 6 == 0 && i != 0) nf++;
3333

34-
students[i] = new Student("Student_name" + to_string(i), nf%3, i%6);
34+
// Converting int to string
35+
// Could use to_string, but not available in c++98
36+
ostringstream str1;
37+
str1 << i;
38+
string temp = str1.str();
39+
40+
students[i] = new Student("Student_name" + temp, nf%3, i%6);
3541
}
3642

3743
int size_teacher = 3 * 6;
@@ -41,7 +47,13 @@ int main(int argc, char* argv[]) {
4147
for (int i=0 ; i<size_teacher ; i++) {
4248
if (i % 6 == 0 && i != 0) nf++;
4349

44-
teachers[i] = new Teacher("Teacher_name" + to_string(i), nf, i%6);
50+
// Converting int to string
51+
// Could use to_string, but not available in c++98
52+
ostringstream str1;
53+
str1 << i;
54+
string temp = str1.str();
55+
56+
teachers[i] = new Teacher("Teacher_name" + temp, nf, i%6);
4557
}
4658

4759

0 commit comments

Comments
 (0)