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 <sstream>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
int A::counter = 0;
|
|
||||||
|
|
||||||
std::string A::g(){
|
std::string A::g(){
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<< "A::g-" << int(pow(i,e));
|
ss<< "A::g-" << i;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string A::f(){
|
std::string A::f(){
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<< "A::f-" << int(pow(i,e));
|
ss<< "A::f-" << i;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
A.h
13
A.h
@ -3,18 +3,17 @@
|
|||||||
|
|
||||||
|
|
||||||
class A{
|
class A{
|
||||||
private:
|
|
||||||
|
|
||||||
static int counter;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string f();
|
std::string f();
|
||||||
int i;
|
int i;
|
||||||
int e;
|
inline static int counter = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
A(){};
|
|
||||||
A(int i):i(i), e(1){};
|
A(){}
|
||||||
|
A(int n):i(n) {counter++;};
|
||||||
|
~A(){counter--;};
|
||||||
|
|
||||||
std::string g();
|
std::string g();
|
||||||
static int anzahlObjekte();
|
static int anzahlObjekte();
|
||||||
|
|||||||
5
B.h
5
B.h
@ -5,10 +5,9 @@ class B : public A{
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int i;
|
int i;
|
||||||
int e=2;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
B(){};
|
B(){}
|
||||||
B(int i) : i(i){};
|
B(int n) : i(n), A(n*n) {};
|
||||||
std::string h();
|
std::string h();
|
||||||
};
|
};
|
||||||
6
C.h
6
C.h
@ -5,9 +5,9 @@ class C : public A{
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int i;
|
int i;
|
||||||
int e=3;
|
|
||||||
public:
|
public:
|
||||||
C(){};
|
C(){}
|
||||||
C(int i) : i(i){};
|
C(int n) : i(n), A(n*n*n) {};
|
||||||
std::string h();
|
std::string h();
|
||||||
};
|
};
|
||||||
3
D.h
3
D.h
@ -6,10 +6,9 @@
|
|||||||
class D: public B, public C{
|
class D: public B, public C{
|
||||||
private:
|
private:
|
||||||
int i;
|
int i;
|
||||||
int e=2;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
D(int i) : i(i){}
|
D(int n) : i(n), B(n), C(n){}
|
||||||
std::string h();
|
std::string h();
|
||||||
std::string g();
|
std::string g();
|
||||||
};
|
};
|
||||||
@ -79,6 +79,7 @@ void PrueffolgeMehrfachvererbung::pruefungObjektgroesse()
|
|||||||
B b(22);
|
B b(22);
|
||||||
C c(23);
|
C c(23);
|
||||||
D d(24);
|
D d(24);
|
||||||
|
cout << sizeof(b) << " " << sizeof(a) << endl;
|
||||||
SICHERSTELLEN(sizeof(b) / sizeof(a) == 2);
|
SICHERSTELLEN(sizeof(b) / sizeof(a) == 2);
|
||||||
SICHERSTELLEN(sizeof(c) / sizeof(a) == 2);
|
SICHERSTELLEN(sizeof(c) / sizeof(a) == 2);
|
||||||
SICHERSTELLEN(sizeof(d) / sizeof(a) == 5);
|
SICHERSTELLEN(sizeof(d) / sizeof(a) == 5);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user