c++ - already defined in persontype error -


i keep error saying membershiptype functions declared created in persontype class wondering how fix error first error message says membershiptime::membershiptype defined in person type object not,and second error message says second construcor defined in persontype how fix error?

#include <iostream> #include <string> using namespace std; class addresstype {  //class defintions , prototypes member variables public:     addresstype();     string streetaddressnum, streetname, streettype, city, stateinitials;     int zipcode; }; class persontype { public:     persontype();     string firstname;     string lastname;     int personnum;     char gender;     int personid;     addresstype address;     void setinterest1(string interest1);//mutator     void setinterest2(string interest2);     void printperson();     string  getinterest1() const;    // accessor     string  getinterest2() const; private:     string setinterest1;     string setinterest2; };  //define membershiptype class class membershiptype :public persontype { public:     char membership_type;     char membership_status;     membershiptype();  // 1st constructor     membershiptype(char, char);  // 2nd constructor     void print_member_type(); };  membershiptype::membershiptype()  {      membership_type = ' ';      membership_status = ' '; }  membershiptype::membershiptype(char members1, char members2)  {      members1 = membership_type;      members2 = membership_status;;  } void membershiptype::print_member_type() {     cout << firstname << " " << lastname << " " << gender << " " <<         personid << " " << address.streetaddressnum << " "         << address.streetname << " " << address.streettype         << " " << address.city << " " << address.stateinitials         << " " << address.zipcode << " " <<membership_status<<membership_type<<endl; }   #include "persontype.h" persontype::persontype() {//constructor     int personnum = 0;     int personid = 0; } addresstype::addresstype() {     int zipcode = 0; } void persontype::setinterest1(string interest1) {     setinterest1 = interest1; }//mutator void persontype::setinterest2(string interest2) {     setinterest2 = interest2; } string persontype::  getinterest1() const {     return setinterest1; }// accessor string persontype:: getinterest2() const {     return setinterest2; }  void persontype :: printperson() {//constructor      cout << firstname << " " << lastname << " " << gender << " " <<         personid << " " << address.streetaddressnum << " "         << address.streetname << " " << address.streettype         << " " << address.city << " " << address.stateinitials         << " " << address.zipcode << " " << setinterest1 << " " << setinterest2 << endl; } 

you need organize class separately :

//main.cpp   #include <iostream> #include <string>  using namespace std; #include "membershiptype.h"   membershiptype::membershiptype() {     membership_type = ' ';     membership_status = ' '; } membershiptype::membershiptype(char members1, char members2) {     members1 = membership_type;     members2 = membership_status;; } void membershiptype::print_member_type() {     cout << firstname << " " << lastname << " " << gender << " " <<     personid << " " << address.streetaddressnum << " "     << address.streetname << " " << address.streettype     << " " << address.city << " " << address.stateinitials     << " " << address.zipcode << " " << membership_status << membership_type << endl; }   persontype::persontype() {//constructor     int personnum = 0;     int personid = 0; } addresstype::addresstype() {     int zipcode = 0; } void persontype::setinterest1(string interest1) {     setinterest1 = interest1; }//mutator void persontype::setinterest2(string interest2) {     setinterest2 = interest2; } string persontype::getinterest1() const {     return setinterest1; }// accessor string persontype::getinterest2() const {     return setinterest2; }  void persontype::printperson() {//constructor      cout << firstname << " " << lastname << " " << gender << " " <<     personid << " " << address.streetaddressnum << " "     << address.streetname << " " << address.streettype     << " " << address.city << " " << address.stateinitials     << " " << address.zipcode << " " << setinterest1 << " " << setinterest2 << endl; }  int main() {     persontype* p = new persontype;     p->printperson(); } 

the persontype.h :

#include "addresstype.h" class persontype { public:     persontype();     std::string firstname;     std::string lastname;     int personnum;     char gender;     int personid;     addresstype address;     void setinterest1(std::string interest1);//mutator     void setinterest2(std::string interest2);     void printperson();     std::string  getinterest1() const;    // accessor     std::string  getinterest2() const; private:     std::string setinterest1;     std::string setinterest2; }; 

you addresstype.h

class addresstype {  //class defintions , prototypes member variables public:     addresstype();     std::string streetaddressnum, streetname, streettype, city, stateinitials;     int zipcode; }; 

your membershiptype.h

//define membershiptype class class membershiptype :public persontype { public:     char membership_type;     char membership_status;     membershiptype();  // 1st constructor     membershiptype(char, char);  // 2nd constructor     void print_member_type(); }; 

1>------ début de la génération : projet : consoleapplication2, configuration : release win32 ------ 1> main.cpp 1> génération de code en cours 1> 52 functions compiled because no usable ipdb/iobj previous compilation found. 1> fin de la génération du code 1> consoleapplication2.vcxproj -> c:\out\frosbite_sdk_typeinfo\sdk\consoleapplication2\release\consoleapplication2.exe ========== génération : 1 réussi, 0 échoué, 0 mis à jour, 0 été ignoré ==========


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -