使用 Visual Studio 编译创建新的客户无休止的编译错误



>伙计们,我在这里做错了什么,我需要使用 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;
}

最新更新