c++ - error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion) -


i'm not sure problem is. gives me error:

error c2679: binary '<<' : no operator found takes right-hand operand of type 'void' (or there no acceptable conversion)

overloaded << shouldn't giving me error, right?

#ifndef animal_h_ #define animal_h_  #include <iostream>  #include <string> using namespace std;  static int counter; static int getanimalcount() { return counter; }  class animal {     protected:        string *animaltype;     public:        virtual void talk() = 0;        virtual void move() = 0;        string getanimaltype() { return *animaltype; }                 //problem right here v         friend ostream& operator<<(ostream&out, animal& animal) {            return out << animal.getanimaltype() << animal.talk() << ", " << animal.move();        };        ~animal() {            counter--;            animaltype = null;        }  };  class reptile : public animal {       public:          reptile() { animaltype = new string("reptile"); };  };  class bird : public animal {      public:          bird() { animaltype = new string("bird"); };  };  class mammal : public animal{      public:          mammal() { animaltype = new string("mammal"); };  };  #endif /* animal_h_ */ 

virtual void talk() = 0; specifies function return type void. means not return anything. same happens when define animal::move virtual void move() = 0;.

out << animal.getanimaltype() << animal.talk() << ", " << animal.move(); tries print result of animal.talk() , result of animal.move() - neither of exists (remember, neither talk() nor move() return value!)


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -