C++ Error C2143 syntax error: missing ";" before "using namespace" -


this code:

#include <iostream> #include "constructors.h"  using namespace std;  int main() {     animal animal1;     animal1.setname("klinton");      animal animal2 = animal1;     animal2.speak();     animal2.setname("freddy");     animal2.speak();      return 0; } 

and code for: "constructors.h":

#ifndef _constructors_h_ #define _constructors_h_ #include <string> class animal { private:     std::string name; public:     animal() { cout << "animal created." << endl; }     animal(const animal& other): name(other.name) { cout << "animal created copying." << endl; }     void setname(std::string name) { this->name = name; }     void speak() const { cout << "my name is: " << name << endl; }  }  #endif // !_constructors_h_ 

the error has number c2143 , says there missing: ";" before: "using namespace" on line 4 in main.cpp, how fix this?

class definitions have end semicolon.

so, class animal{...};


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -