A.cpp compiliert, aber mit Fehlern

This commit is contained in:
regis37 2025-11-25 14:16:47 +01:00
parent 3dce2315ee
commit e17a9dabd8
7 changed files with 15 additions and 18 deletions

5
A.cpp
View File

@ -2,17 +2,16 @@
#include <sstream>
#include <math.h>
int A::counter = 0;
std::string A::g(){
std::stringstream ss;
ss<< "A::g-" << int(pow(i,e));
ss<< "A::g-" << i;
return ss.str();
}
std::string A::f(){
std::stringstream ss;
ss<< "A::f-" << int(pow(i,e));
ss<< "A::f-" << i;
return ss.str();
}

13
A.h
View File

@ -3,18 +3,17 @@
class A{
private:
static int counter;
protected:
std::string f();
int i;
int e;
int i;
inline static int counter = 0;
public:
A(){};
A(int i):i(i), e(1){};
A(){}
A(int n):i(n) {counter++;};
~A(){counter--;};
std::string g();
static int anzahlObjekte();

5
B.h
View File

@ -5,10 +5,9 @@ class B : public A{
private:
int i;
int e=2;
public:
B(){};
B(int i) : i(i){};
B(){}
B(int n) : i(n), A(n*n) {};
std::string h();
};

6
C.h
View File

@ -5,9 +5,9 @@ class C : public A{
private:
int i;
int e=3;
public:
C(){};
C(int i) : i(i){};
C(){}
C(int n) : i(n), A(n*n*n) {};
std::string h();
};

3
D.h
View File

@ -6,10 +6,9 @@
class D: public B, public C{
private:
int i;
int e=2;
public:
D(int i) : i(i){}
D(int n) : i(n), B(n), C(n){}
std::string h();
std::string g();
};

View File

@ -79,6 +79,7 @@ void PrueffolgeMehrfachvererbung::pruefungObjektgroesse()
B b(22);
C c(23);
D d(24);
cout << sizeof(b) << " " << sizeof(a) << endl;
SICHERSTELLEN(sizeof(b) / sizeof(a) == 2);
SICHERSTELLEN(sizeof(c) / sizeof(a) == 2);
SICHERSTELLEN(sizeof(d) / sizeof(a) == 5);

BIN
main.exe

Binary file not shown.