c++ - City Data Attribute -
so have been trying add population attribute city. think have keep getting error "requires type specifier declarations".
// citytest.cpp #include <iostream> #include <cstdlib> #include <cstring> using namespace std; class city { char name[12]; char population [6]; public: city( char input[] ) { strcpy( name, input ); } char* getname() { return name; } popn( char input[] ) <--- bit cause error { strcpy( population, input ); } char* getpop() { return population; } }; int main( void ) { city acity( "cambridge" ); cout << "city is: " << acity.getname() << endl; city pop( "300000" ); cout << "city population: " << pop.getpop() << endl; return 0; }
hopefully enough suggest why doing this.
Comments
Post a Comment