簡體   English   中英

程序沒有運行

[英]The program isn't running

這是我的代碼:

#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;

}

我的錯誤在哪里?

第一個問題:將#include <string.h>添加到您的項目中!

第二個問題:在void setAddress(string SA, string C, string SA, int Z);雙重聲明 SA void setAddress(string SA, string C, string SA, int Z);

第三個問題是重新定義

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

等等...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM