A.cpp compiliert, aber mit Fehlern
This commit is contained in:
parent
3dce2315ee
commit
e17a9dabd8
5
A.cpp
5
A.cpp
@ -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
13
A.h
@ -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
5
B.h
@ -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
6
C.h
@ -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
3
D.h
@ -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();
|
||||
};
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user