该程序未运行

时间:2015-11-14 01:53:41

标签: c++

这是我的代码:

#include <iostream>

using namespace std;

class addressType
{
  public:
         void setAddress(string SA, string C, string SA, int Z);
         string getCity();
         string getState();
         int getZipCode();
         string getStreetAddress():
/* I think I did something wrong here because the error is saying that only constructors take base initialization. I am not sure where I went wrong...*/

         addressType();
/* Another error is that addressType isn't the direct base of addressType */

  private: 
      string city;
      string state;
      int zipCode;
      string streetAddress;
};

void addressType::setAddress(string SA, string C, string S, int Z)
{
 city = C;
 state = S;
 zipCode = Z;
 streetAddress = SA;
}
/* I am also not sure if I can set all the variables in one function rather than setting the variables in separate functions. */

string addressType::getCity()
{
   return city;
}

string addressType::getState()
{
   return state;
}
int addressType::getZipCode()
{
return zipCode;
}
string addressType::getStreetAddress()
{
return streetAddress;
}

addressType::addressType()
{
city = " ";
state = " ";
zipCode = 0;
streetAddress = " ";
}

int main()
{
string City,State,streetAddress;
int ZipCode;

addressType address;
cout << "Please enter your street address(example: 38-98)" << endl
cin >> stressAddress;
cout << "Please enter City" << endl;
cin >> City;
cout << "Please enter your state: " << andl;
cin >> State;
cout << "please enter your zipcode" << endl;
cin >> ZipCode;
address.setAddress(streetAddress, City, State, ZipCode);
system("Pause");
return 0;

}

我的错误在哪里?

1 个答案:

答案 0 :(得分:0)

第一个问题:将#include <string.h>添加到您的项目中!

第二个问题:在void setAddress(string SA, string C, string SA, int Z);

中双重声明SA

第三个问题是重新定义

string addressType::getStreetAddress()
{
return streetAddress;
}

依旧......

相关问题