C++ 错误:聚合的类型不完整,无法定义

C++ 错误:聚合的类型不完整,无法定义,c++,c++11,incomplete-type,C++,C++11,Incomplete Type,我正在为银行编写一个程序,在编译它时,我遇到了这个错误。 这是我的全部代码,因为我无法在这里共享更多的代码,它位于粘贴箱上 我不包括我的全部代码,但包括我认为应该负责的部分: #include<iostream> #include<string> #include<limits> #include<fstream> #include<iomanip> using std::ios_base; using std::ostringstr

我正在为银行编写一个程序,在编译它时,我遇到了这个错误。 这是我的全部代码,因为我无法在这里共享更多的代码,它位于粘贴箱上

我不包括我的全部代码,但包括我认为应该负责的部分:

#include<iostream>
#include<string>
#include<limits>
#include<fstream>
#include<iomanip>

using std::ios_base;
using std::ostringstream;
using std::ios;
using std::fstream;
using std::ifstream;
using std::ofstream;
using std::stoi;
using std::to_string;
using std::string;
using std::cout;
using std::cin;
using std::endl;
using std::getline;

class yourbankaccount
{
private:
    string accountNumber;
    // Name of the customer.
    string name;
    // Date of birth
    int day;
    int month;
    int year;
    // Get Age
    int age;
    // Get Gender
    string gender;
    long accountBalance = 0;
public:
    friend int getInt(string info, int length);
    friend string getStr(string info, int length);
    yourbankaccount(){}
    void setAccountNumber(string number){
        accountNumber = number;
    }
    string shareAccountNumber(){
        return accountNumber;
    }
    // Get date
    void getDate(){
        int d, m, y;
        cout << "Now please enter your Date Of Birth(DD/MM/YYYY):"<<endl;
        d = getInt("Day(DD)", 2);
        m = getInt("Month(MM)", 2);
        y = getInt("Year(YYYY)", 4);
        day = d; month = m; year = y;
    }
    // Return Date
    string sendDate(){
        string Date = to_string(day) + "/" + to_string(month) + "/" + to_string(year);
        return Date;
    }
    // Method to add details.
    void getCustomerDetails(){
        bool gotGen = false;
        string n; int a; unsigned int p; char g;
        cout << "Please fill in the following details: ";
        name = getStr("Name of Account holder", 45);
        cout << "Enter your birthday in given format: ";
        getDate();
        age = getInt("your Age", 2);
        do
        {
            gender = getStr("your Gender(only M for Male, F for Female, O for Other)", 1);
            if (stringToUpper(gender)  != "M" || 
                stringToUpper(gender) != "F" || 
                stringToUpper(gender) != "O"){
                    "Please enter only M or F or O!";
            }else{
                gotGen = true;
            }
        } while (gotGen);
    } 
    string shareName(){
        return name;
    }
    string shareDOB(){
        return sendDate();
    }
    int shareAge(){
        return age;
    }
    string shareGender(){
        return gender;
    }
    void setAccountBalance(long bal){
        accountBalance = bal;
    }
    long shareAccountBalance(){
        return accountBalance;
    }
    ~yourbankaccount(){}
};

#包括
#包括
#包括
#包括
#包括
使用std::ios_base;
使用std::ostringstream;
使用std::ios;
使用std::fstream;
使用std::ifstream;
使用std::of流;
使用std::stoi;
使用std::to_字符串;
使用std::string;
使用std::cout;
使用std::cin;
使用std::endl;
使用std::getline;
给你的银行账户分类
{
私人:
字符串accountNumber;
//客户的姓名。
字符串名;
//出生日期
国际日;
整月;
国际年;
//变老
智力年龄;
//获得性别
字符串性别;
长期账户余额=0;
公众:
friend int getInt(字符串信息,整数长度);
好友字符串getStr(字符串信息,整数长度);
您的银行帐户(){}
void setAccountNumber(字符串编号){
accountNumber=数字;
}
字符串shareAccountNumber(){
返回帐号;
}
//约会
void getDate(){
int d,m,y;

cout您的类类型是。您需要在声明该类的对象之前声明该类。这对该类是不够的。

请按要求在此处发布一个。可能您没有将定义
yourbankaccount
的标题包含到尝试使用它的源文件中。我在同一个文件中定义了它内德还是声明?请创建一个合适的。一个好的是我们可以复制并构建自己,以复制您所问的确切错误(但仅此而已)。请记住最基本的部分,您当前显示的大多数代码与问题无关。请不要发布代码链接。相反,发布一个。若要创建一个链接,请获取整个代码并开始丢弃不相关的部分。每次,请验证您是否仍然收到相同的错误。一旦您不能再丢弃任何内容,您将有一个错误。
void createAccount(){
    ofstream addAccount;
    yourbankaccount Account;
    cout << "Thank You for Choosing Your Bank.";
    cout << "Please provide The folling details.";
    Account.setAccountNumber(calNewAccNumber());
    Account.getCustomerDetails();
    Account.setAccountBalance(500);
    int pin = getInt("a pin for the account", 4);
    string file ="accounts/open.csv";
    addAccount.open(file, ios::out | ios::app);
    if (addAccount.is_open())
    {
        addAccount << Account.shareAccountNumber()
        << "," << pin << "," << "\"" << Account.shareName() << "\"" << "," 
        << Account.shareDOB() <<"," << Account.shareAge()
        << "," << Account.shareGender() << Account.shareAccountBalance()<<"\n";
    }

    cout << "Your Account has been created Sucessfully." <<
            "Please note your number as it will be required for logging in\n";
    cout << "Account number is:" << Account.shareAccountNumber() << "\n";
}
> Executing task: C/C++: g++.exe build active file ver(1) <

Starting build...
D:\Programs\mingw_w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\g++.exe -g D:\BSC_IT\sem_2\OOPS\CA2\YourBank\yourbank.cpp -o 
D:\BSC_IT\sem_2\OOPS\CA2\YourBank\yourbank.exe
```
D:\BSC_IT\sem_2\OOPS\CA2\YourBank\yourbank.cpp: In function 'void createAccount()':
D:\BSC_IT\sem_2\OOPS\CA2\YourBank\yourbank.cpp:139:21: error: aggregate 'yourbankaccount Account' has incomplete type and cannot be defined
    yourbankaccount Account;
                     ^~~~~~~
```
Build finished with error(s).
The terminal process terminated with exit code: -1.

>Terminal will be reused by tasks, press any key to close it.