diff --git a/casts.cpp b/casts.cpp index 53796d0..b42313a 100644 --- a/casts.cpp +++ b/casts.cpp @@ -2,12 +2,12 @@ #include class mybase { - protected: - std::string ids; + protected: + std::string ids; - public: - mybase(std::string ids) - : ids(ids) {} + public: + mybase(std::string ids) + : ids(ids) {} virtual void foo() { std::cout << "i'm a mybase! ids: " << ids << std::endl; @@ -15,7 +15,7 @@ class mybase { }; class myclass : public mybase { - public: + public: myclass(std::string ids) : mybase(ids) {} diff --git a/classes.cpp b/classes.cpp index f59a23c..71c2a32 100644 --- a/classes.cpp +++ b/classes.cpp @@ -2,39 +2,39 @@ #include class Animal { - public: - Animal() { - std::cout << "constructor" << std::endl; - } - Animal(const Animal& other) { - std::cout << "copy constructor (" << &other << ")" << std::endl; - } - - // Note: using *virtual* does the difference here! - virtual void makeSound() const { - std::cout << " from " << this << std::endl; - } - - Animal& operator= (Animal &a) { - std::cout << "lol, operator= of " << this; - std::cout << "(arg: " << &a << ")" << std::endl; - - return *this; - } + public: + Animal() { + std::cout << "constructor" << std::endl; + } + Animal(const Animal& other) { + std::cout << "copy constructor (" << &other << ")" << std::endl; + } + + // Note: using *virtual* does the difference here! + virtual void makeSound() const { + std::cout << " from " << this << std::endl; + } + + Animal& operator= (Animal &a) { + std::cout << "lol, operator= of " << this; + std::cout << "(arg: " << &a << ")" << std::endl; + + return *this; + } }; class Cow : public Animal { - public: - void makeSound() const { - std::cout << "Mooh. from " << this << std::endl; - } + public: + void makeSound() const { + std::cout << "Mooh. from " << this << std::endl; + } }; class Cat : public Animal { - public: - void makeSound() const { - std::cout << "Meow? from " << this << std::endl; - } + public: + void makeSound() const { + std::cout << "Meow? from " << this << std::endl; + } }; void call(Animal a) { diff --git a/poly.cpp b/poly.cpp index 1dfaf1e..320658c 100644 --- a/poly.cpp +++ b/poly.cpp @@ -3,11 +3,11 @@ /* abstract */ class Animal { - public: - // virtual std::string talk() = 0; /* pure virtual */ - virtual std::string talk() { /* or an implementation */ - return ""; - } + public: + // virtual std::string talk() = 0; /* pure virtual */ + virtual std::string talk() { /* or an implementation */ + return ""; + } }; class Cat : public Animal {