Khemp
Khemp

Reputation: 1

ClassName does not have a type

I've run into a slight issue getting my program to compile. This is the first time I've worked with code being spread out between multiple files and it's giving me some issues. I suppose my main issue is the 'CreditAccount' does not name a type error.

CreditAccount.h

#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; 
}

assign2.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;
}

I'm pretty lost here, and any help would be greatly appreciated.

Upvotes: 0

Views: 84

Answers (1)

Tim Bergel
Tim Bergel

Reputation: 495

The line at the start of CreditAccount.h:

#ifdef  CREDIT_ACCOUNT_H

is wrong, it should be:

#ifndef  CREDIT_ACCOUNT_H

to make sure that the file is only included once (instead of never getting included).

Upvotes: 2

Related Questions