C++ ClassName没有类型

C++ ClassName没有类型,c++,header,C++,Header,我在编译程序时遇到了一个小问题。这是我第一次处理在多个文件之间分布的代码,这给了我一些问题。 我想我的主要问题是“CreditAccount”没有命名类型错误 信用账户 #ifdef CREDIT_ACCOUNT_H #define CREDIT_ACCOUNT_H class CreditAccount { private: char accountNum[20]; char custName[21]; double credLimit

我在编译程序时遇到了一个小问题。这是我第一次处理在多个文件之间分布的代码,这给了我一些问题。 我想我的主要问题是“CreditAccount”没有命名类型错误

信用账户

#ifdef  CREDIT_ACCOUNT_H
#define CREDIT_ACCOUNT_H
class CreditAccount
{
    private:
        char accountNum[20];
        char custName[21];
        double credLimit;
        double accountBal;  

    public;
        CreditAccount();
        CreditAccount(char[], char[], double, double);  
};

#endif
CreditAccount.cpp

#include "CreditAccount.h"
#include <cstring>
CreditAccount::CreditAccount()
{
accountNum[0] = '\0';
custName[0] = '\0';
credLimit = 0;
accountBal = 0;
}

CreditAccount::CreditAccount(char newAccountNum[], char newCustName[], double newCredLimit, double newAccountBal)
{
newAccountNum = strcpy(newAccountNum, accountNum);
newCustName = strcpy(newCustName, custName);
newCredLimit = credLimit;
newAccountBal = accountBal; 
}
#包括“CreditAccount.h”
#包括
CreditAccount::CreditAccount()
{
accountNum[0]='\0';
客户名称[0]='\0';
credLimit=0;
accountBal=0;
}
CreditAccount::CreditAccount(char newAccountNum[],char newCustName[],double newCredLimit,double newAccountBal)
{
newAccountNum=strcpy(newAccountNum,accountNum);
newCustName=strcpy(newCustName,custName);
newCredLimit=credLimit;
newAccountBal=accountBal;
}
2.cpp

#include <iostream>
#include "CreditAccount.h"

using std::cout;
using std::endl;

int main()
{
char code1[20] = "1111-1111-1111-1111";
char name1[21] = "Jermaine Arnold";
char code2[20] = "2222-2222-2222-2222";
char name2[21] = "Vanessa Long";

// Test default constructor
CreditAccount account1;
return 0;
}
#包括
#包括“CreditAccount.h”
使用std::cout;
使用std::endl;
int main()
{
字符代码1[20]=“1111-1111-1111-1111”;
char name1[21]=“Jermaine Arnold”;
字符代码2[20]=“2222-2222-2222-2222”;
字符名称2[21]=“Vanessa Long”;
//测试默认构造函数
贷记账户1;
返回0;
}

我在这里迷路了,任何帮助都将不胜感激。

CreditAccount开头的行。h:

#ifdef  CREDIT_ACCOUNT_H
如果是错误的,应该是:

#ifndef  CREDIT_ACCOUNT_H

确保该文件只包含一次(而不是从不包含)。

public
应该是
public:
CreditAccount.h
中。为什么不使用
std::string
?对不起,public;这是我之前注意到的,但忘记了更改。如果您实现我和Tim Bergel建议的更正,您的程序应该可以编译。您可能会收到关于strcpy的警告。我收到了一个“id returned 1 exit status error”是不是因为我的源代码还没有做任何事情?