File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed
Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -22,12 +22,26 @@ CFraction::~CFraction() {
2222
2323CFraction::CFraction (int num, int den) {
2424 mp_numerator = new int ();
25- *mp_numerator = num;
2625 mp_denumerator = new int ();
26+
27+ *mp_numerator = num;
2728 *mp_denumerator = den;
29+
2830 clog << " Num: " << *mp_numerator << " , Den: " << *mp_denumerator << endl;
2931}
3032
33+ CFraction::CFraction (const CFraction &fraction) {
34+ // 1. Versuch
35+ // this->CFraction(*(fraction.mp_numerator),*(fraction.mp_denumerator));
36+ // 2. Versuch
37+ mp_numerator = new int ();
38+ mp_denumerator = new int ();
39+
40+ *mp_numerator = *fraction.mp_numerator ;
41+ *mp_denumerator = *fraction.mp_denumerator ;
42+ clog << " Num: " << *mp_numerator << " , Den: " << *mp_denumerator << endl;
43+
44+ }
3145void CFraction::writeln () {
3246 cout << " Num: " << *mp_numerator << " , Den: " << *mp_denumerator << endl;
3347}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ class CFraction {
1313 CFraction ();
1414 virtual ~CFraction ();
1515 CFraction (int num, int den);
16+ CFraction (const CFraction &fraction);
1617 void writeln ();
1718
1819private:
Original file line number Diff line number Diff line change @@ -11,11 +11,13 @@ using namespace std;
1111#include " CFraction.h"
1212
1313int main () {
14- CFraction zahl1 (3 ,4 );
14+ CFraction zahl1 (3 , 4 );
1515 CFraction zahl2;
16+ CFraction zahl3 (zahl1);
1617
1718 zahl1.writeln ();
1819 zahl2.writeln ();
20+ zahl3.writeln ();
1921
2022 return 0 ;
2123}
You can’t perform that action at this time.
0 commit comments