程序未运行
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
第三个问题是的重新定义
string addressType::getStreetAddress()
{
return streetAddress;
}
等等…
相关文章:
- 运行程序时出现问题
- 分段错误当我试图运行程序时出错
- C++ 每次运行程序时我都会"nan"输出的问题
- 通过 g++ 运行程序时没有这样的文件或目录
- 重新运行程序和字符串流?
- 无法在 VS Code 上使用代码运行程序运行C++文件
- 使用有限的 RAM 运行 c++ 程序
- 继续运行程序而无需任何干预,直到要求退出为止
- 如何在每次运行程序时写入文件的下一行?
- 控制台在运行C ++程序后立即关闭(无需调试)
- 运行程序时找不到共享对象库,但在编译过程中链接了它
- 远程运行程序
- 在 Heroku 上运行 C++ 程序
- 如何在Powershell中运行C++程序,就像CMD一样?
- 为什么与Java和Python相比,使用Cmake运行C++程序每次都需要这么长时间?
- C++随机数生成器通常在 Visual Studio 中运行程序时在 2 次后停止生成数字
- 崇高文本 3 - 在终端中编译并运行 C++ 程序(路径包含空格)
- 我收到阻止我运行程序的警告,但不确定如何解决
- C++ Visual Studio 无法完全运行程序
- 在SIGABRT c ++信号之后继续运行程序