Skip to content

Commit ea9f978

Browse files
author
Torben
committed
ostream optimiert
1 parent 1faddfd commit ea9f978

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/String.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@ String& String::operator+=(String& s) {
7373
str = newStr;
7474
return *this;
7575
}
76+
77+
ostream& operator<<(ostream &out, String &s) {
78+
for (int i = 0; i < s.size; i++) {
79+
out << s.str[i];
80+
}
81+
82+
return out;
83+
}

src/testString.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
#include "String.h"
22

3-
ostream& operator<<(ostream &out, String &s) {
4-
for (int i = 0; i < s.size; i++) {
5-
out << s.str[i];
6-
}
7-
8-
return out;
9-
}
10-
113
int main() {
4+
125
String s;
136
String s2('H');
147
String s3("Hallo");

0 commit comments

Comments
 (0)