Skip to content
Snippets Groups Projects
Commit 04a640c8 authored by Alexander Steinmaurer's avatar Alexander Steinmaurer
Browse files

Lecture 9

parent 017bb450
No related branches found
No related tags found
No related merge requests found
#include <iostream>
#include <string>
class Muggle {
private:
std::string job_;
public:
Muggle(std::string job) : job_(job) { }
std::string getJob () const {
return job_;
}
};
class Wizard {
private:
std::string house_;
public:
Wizard(std::string house) : house_(house) { }
std::string getHouse () const {
return house_;
}
};
class Halfblood : public Muggle, public Wizard {
private:
bool isMotherMuggle_;
bool isFatherMuggle_;
public:
Halfblood(std::string job, std::string house,
bool muggleMother, bool muggleFather) : Muggle(job),
Wizard(house), isMotherMuggle_(muggleMother),
isFatherMuggle_(muggleFather) { }
};
int main()
{
Halfblood severus_snape("Teacher", "Slytherin", false, true);
return 0;
}
\ No newline at end of file
#include <iostream>
#include <string>
class Muggle {
private:
std::string name_;
public:
Muggle(std::string name) : name_(name) { }
std::string getName () const {
return name_;
}
};
class Wizard {
private:
std::string name_;
public:
Wizard(std::string name) : name_(name) { }
std::string getName () const {
return name_;
}
};
class Halfblood : public Muggle, public Wizard {
private:
bool isMotherMuggle_;
bool isFatherMuggle_;
public:
Halfblood(std::string m_name, std::string w_name,
bool muggleMother, bool muggleFather) : Muggle(m_name),
Wizard(w_name), isMotherMuggle_(muggleMother),
isFatherMuggle_(muggleFather) {}
};
int main()
{
Halfblood he_who_must_not_be_named("Tom Riddle", "Lord Voldemort",
false, true);
std::cout << he_who_must_not_be_named.getName();
return 0;
}
\ No newline at end of file
#include <iostream>
#include <string>
struct Person {
Person() { std::cout << "Person Konstruktor" << std::endl; }
};
struct Muggle : public Person {
Muggle() { std::cout << "Muggle Konstruktor" << std::endl; }
};
struct Wizard : public Person {
Wizard() { std::cout << "Wizard Konstruktor" << std::endl; }
};
struct Halfblood : public Muggle, public Wizard {
Halfblood() { std::cout << "Halfblood Konstruktor" << std::endl; }
};
int main()
{
Halfblood he_who_must_not_be_named;
}
//Person Konstruktor
//Muggle Konstruktor
//Person Konstruktor
//Wizard Konstruktor
//Halfblood Konstruktor
\ No newline at end of file
#include <iostream>
#include <string>
struct Person {
Person() { std::cout << "Person Konstruktor" << std::endl; }
};
struct Muggle : virtual public Person {
Muggle() { std::cout << "Muggle Konstruktor" << std::endl; }
};
struct Wizard : virtual public Person {
Wizard() { std::cout << "Wizard Konstruktor" << std::endl; }
};
struct Halfblood : public Muggle, public Wizard {
Halfblood() { std::cout << "Halfblood Konstruktor" << std::endl; }
};
int main()
{
Halfblood he_who_must_not_be_named;
}
//Person Konstruktor
//Muggle Konstruktor
//Wizard Konstruktor
//Halfblood Konstruktor
\ No newline at end of file
#include <iostream>
#include <string>
struct Species {
void fly() { }
};
struct Human : Species {
std::string blood_group;
};
struct Kree : public Species {
//Kree things
};
struct Titan : public Species {
//Titan things
};
struct Hero : Human Human {
//Hero things
};
struct Enemie : public Human, public Kree, public Titan {
void makeEvilPlans() { }
};
\ No newline at end of file
class Helmet {
};
class Arm {
void raise() {}
};
class Legs {
void move() {}
};
class Corpus {
};
class Weapon {
void ShootRocket() {}
};
class Mark {
Helmet h;
Corpus c;
Arm arms[2];
Legs legs[2];
};
int main()
{
Mark mark1;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment