簡體   English   中英

我有一個未聲明的標識符錯誤,我無法弄清楚

[英]I have an undeclared identifier error, that I can't figure out

我不知道為什么這行不通。 當我運行它時,我在對象c1和客戶上遇到各種未聲明的標識符錯誤。 如果我做一個客戶* c1 = new Customer(); 我仍然遇到相同的錯誤,它不會讓我setcustomerID。 這可能是愚蠢的,任何輸入都會很棒。

void checkout(){

    srand(time(NULL));
    int random = rand() % 3 + 1;

    Customer c1;
    c1.setcustomerID("0");
}




class Customer{
public:
    string customerID;
    string list;
public:
    Customer(){}
    ~Customer(){}



    string getcustomerID(){
        return customerID;
    }
    string getList(){
        return list;
    }
    void setcustomerID(string x){
        customerID = x;
    }
    void setList(int x){
        if(x==1)
            list = "bread";
        if(x==2)
            list = "eggs";
        if(x==3)
            list = "cheese";
    }

};

您應該輸入:

class Customer{

在您的checkout()方法之前

暫無
暫無

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

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