使用 Visual Studio 编译创建新的客户无休止的编译错误
creating a new customer-endless compile errors using Visual Studio compile
>伙计们,我在这里做错了什么,我需要使用 int main 创建一个新客户来调用它,下面的代码.....Visual Studio 编译器只是有无穷无尽的错误,任何人都可以提供修复吗?非常感谢。希望这是足够的细节...
#include <iostream> #include <iomanip> #include <string> #define CUSTOMER_H #indef CUSTOMER_H using namespace std; struct customer { string name; string pin; string user_id; }; int main () {customer* CreateCustomer(const string& name, const string& id, const string& pin); return new customer{ name, id, pin }; cout << new customer << endl; } { customer* Mary = CreateCustomer("Mary Jones", "235718", "5074"); } return customer; }
我会的,但这将是最后一次。 Aurisdante是对的,如果你要追求编程,你确实需要一本关于C++编程的书。我最初的反应是a)因为我记得我刚开始的时候。B)给你一些至少可以编译的东西。所以,从现在开始,由你来征服......
#include <iostream>
#include <iomanip>
#include <string>
#ifndef CUSTOMER_H //CUSTOMER_H not defined
#define CUSTOMER_H //define it
#endif // CUSTOMER_H
using namespace std;
struct customer
{
string name;
string pin;
string user_id;
};
//You have to do this after you prototype the object so the complier knows what the object is
customer* CustomerCreator();
customer* CustomerCreator(string name, string pin, string u_Id);
int main()
{
customer* Customer1 = new customer { "Mary Jones", "235718", "5074" };
cout << Customer1->name << Customer1->pin << endl;
customer* Customer2 = CustomerCreator();
Customer2->name = "Put name here";
Customer2->pin = "0U812";
Customer2->user_id = "AnotherNumberGoesHere";
customer* Customer3 = CustomerCreator("William Shatner", "UCC-1", "HMFIC");
//this creates a break point
_asm int 3;
return 1;
}
//this just creates and returns an object custmer
customer* CustomerCreator()
{
customer* Customer = new customer();
return Customer;
}
customer* CustomerCreator(string name, string pin, string u_Id)
{
customer* Customer = new customer{ name , pin, u_Id};
return Customer;
}
你可能想尝试这样的事情:
#include <iostream>
#include <iomanip>
#include <string>
#ifndef CUSTOMER_H //CUSTOMER_H not defined
#define CUSTOMER_H //define it
#endif // CUSTOMER_H
using namespace std;
struct customer
{
string name;
string pin;
string user_id;
};
int main()
{
customer* CreateCustomer = new customer { "Mary Jones", "235718", "5074" };
cout << CreateCustomer->name << CreateCustomer->pin << endl;
//this creates a break point
_asm int 3;
return 1;
}
相关文章:
- 泛美卫生组织 CPP 客户端由于误用MQTTAsync_connectOptions而无法编译
- 编译 Java TD 客户端时出现构建错误
- 在 Ubuntu 上编译 Protobuf 客户端代码,但找不到包含文件
- 在Windows上编译Mongo DB客户端示例时,链接器错误
- 编译基于 sCrypt 的加密货币 QT 客户端时,抛出常见错误
- UDP客户端-服务器程序使用gcc而不是g++进行编译
- Bash 脚本编译和运行多个服务器和客户端 c.
- 使用 VS2010 在客户端中编译本机 COM 客户端存根
- Google 的原生客户端和编译 SDL2
- 正在为客户端/服务器编译项目[Linker error]未定义对的引用
- 发布编译旧版0.9.0 c++客户端
- 用C++编译gpsd客户端
- 如何将多个gsoap客户端web服务编译成一个可执行文件
- 在Microsoft Visual c++ 2015中编译DLL -警告C4251需要有DLL接口供类的客户端使用-当使
- 如果我用较新版本的gcc编译二进制文件,我如何找到需要在客户机linux机器上安装的库?
- 如果接口的头改变,为什么需要重新编译接口的客户端
- Boost同步服务器客户端编译错误
- 如何在客户端PC中使用编译后的DLL而不安装Windows SDK ?
- 服务器设置在编译时保持打印"connected"即使没有连接客户端
- 可以在不重新编译客户端代码的情况下扩展虚拟接口吗?