when i build this project in vs2010, error occurs:
- syntax error : missing ';' before identifier 'b'
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2065: 'b' : undeclared identifier
#ifndef _B_H #define _B_H #include <string> class B { public: B(); ~B(); void showfunc(); string b; }; #endif /***************************/ // B.cpp #include <iostream> #include <string> #include "B.h" using namespace std; B::B() { } void B::showfunc() { cout<<b<<endl; } /**************************************/ // main.cpp #include <iostream> // #include "B.h" using namespace std; void main() { }
Please help me!
string
is in thestd
namespace. You needstd::string b;
– juanchopanza