I am trying to understand what I am doing wrong. I have been able to eliminate some errors by reading topics. The not a class or struct does not make any sense to me.
I am getting the following errors:
31 IntelliSense: not a class or struct name c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\checkingaccount.h 5 24 Inheritance
33 IntelliSense: expected a ')' c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\savingsaccount.h 15 57 Inheritance
32 IntelliSense: "BankAccount" is not a nonstatic data member or base class of class "SavingAccount" c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\savingsaccount.h 15 41 Inheritance
Error 10 error C2614: 'SavingAccount' : illegal member initialization: 'BankAccount' is not a base or member c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\savingsaccount.h 16 1 Inheritance
Error 2 error C2614: 'CheckingAccount' : illegal member initialization: 'BankAccount' is not a base or member c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\checkingaccount.h 18 1 Inheritance
Error 1 error C2504: 'BankAccount' : base class undefined c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\checkingaccount.h 6 1 Inheritance
Error 9 error C2504: 'BankAccount' : base class undefined c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\savingsaccount.h 6 1 Inheritance
Error 23 error C2228: left of '.withDrawAmount' must have class/struct/union c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\mainfunction.cpp 59 1 Inheritance
Error 29 error C2228: left of '.withDrawAmount' must have class/struct/union c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\mainfunction.cpp 108 1 Inheritance
Error 24 error C2228: left of '.showAccountInfo' must have class/struct/union c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\mainfunction.cpp 66 1 Inheritance
Error 30 error C2228: left of '.showAccountInfo' must have class/struct/union c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\mainfunction.cpp 113 1 Inheritance
Error 22 error C2228: left of '.depositAmount' must have class/struct/union c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\mainfunction.cpp 52 1 Inheritance
Error 28 error C2228: left of '.depositAmount' must have class/struct/union c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\mainfunction.cpp 101 1 Inheritance
Error 25 error C2079: 'sObj' uses undefined class 'SavingAccount' c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\mainfunction.cpp 88 1 Inheritance
Error 19 error C2079: 'obj' uses undefined class 'CheckingAccount' c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\mainfunction.cpp 36 1 Inheritance
Error 20 error C2078: too many initializers c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\mainfunction.cpp 36 1 Inheritance
Error 26 error C2078: too many initializers c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\mainfunction.cpp 88 1 Inheritance
Error 4 error C2065: 'endl' : undeclared identifier c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\checkingaccount.h 69 1 Inheritance
Error 6 error C2065: 'endl' : undeclared identifier c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\checkingaccount.h 83 1 Inheritance
Error 8 error C2065: 'endl' : undeclared identifier c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\checkingaccount.h 85 1 Inheritance
Error 12 error C2065: 'endl' : undeclared identifier c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\savingsaccount.h 33 1 Inheritance
Error 14 error C2065: 'endl' : undeclared identifier c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\savingsaccount.h 52 1 Inheritance
Error 16 error C2065: 'endl' : undeclared identifier c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\savingsaccount.h 53 1 Inheritance
Error 3 error C2065: 'cout' : undeclared identifier c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\checkingaccount.h 69 1 Inheritance
Error 5 error C2065: 'cout' : undeclared identifier c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\checkingaccount.h 83 1 Inheritance
Error 7 error C2065: 'cout' : undeclared identifier c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\checkingaccount.h 85 1 Inheritance
Error 11 error C2065: 'cout' : undeclared identifier c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\savingsaccount.h 33 1 Inheritance
Error 13 error C2065: 'cout' : undeclared identifier c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\savingsaccount.h 52 1 Inheritance
Error 15 error C2065: 'cout' : undeclared identifier c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\savingsaccount.h 53 1 Inheritance
class CheckingAccount: BankAccount
{
//Data members
double balance;
double interest;
double minBal;
double serviceCharge;
double accountNumber;
public://Constructore
CheckingAccount(int ano,double amount,double interest):BankAccount( ano, amount)
{
interest= interest;
minBal=500;//By default
}
//To set interest rate
void setInterestRate(double irate)
{
interest=irate;
}
//to get interest rate
double retrieveInterestRate()
{
return(interest);
}
//to set minimum balance
void setMinBal(double mbal)
{
minBal=mbal;
}
//To get minimum balance
double retrieveMinBal()
{
return(minBal);
}
//To set service charge
void setServiceCharge(double scharge)
{
serviceCharge=scharge;
}
//To get service charge
double retrieveServiceCharge()
{
return(serviceCharge);
}
//To perform deposit
//overriding base class function
double depositAmount(double damount)
{
balance=balance+damount;
return(balance);
}
//to perform withdraw
//overriding base class function
double withDrawAmount(double wamount)
{
//Checking for account have sufficient balance or not
if(check())
balance=balance-wamount;
else
cout<<"You have in sufficient balance"<<endl;
return(balance);
}
//Check function for verifying balance
bool check()
{
if(balance<minBal)
return(false);
else
return(true);
}
//To display account information
void showAccountInfo()
{
cout<<"Account Number :"<<accountNumber<<endl;
cout<<"Account Balance:"<<balance<<endl;
}
};
[BankAccount.h]
//Data members
public:
int accountNumber;
double balance;
public:
//Constructor
BankAccount(int ano,double bal)
{
accountNumber=ano;
balance=bal;
}
BankAccount() { }
public:
//Accessor methods for getting balance
double getBalance()
{
return(balance);
}
//Accessor methods for getting account number
int getAccountNumber()
{
return(accountNumber);
}
//Mutuator method to set balance
void setBalance(double amount)
{
balance=amount;
}
//Setting account number
void setAccountNumber(int ano)
{
accountNumber=ano;
}
//show account information
void showAccountInfo()
{
cout<<"Account Number :"<<accountNumber<<endl;
cout<<"Account Balance:"<<balance<<endl;
}
//function to perform deposit
double depositAmount(double damount)
{
c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\checkingaccount.h 5 24 Inheritance
33 IntelliSense: expected a ')' c:\users\terry\documents\visual studio
I am use to cnc programming, where you name it once in the main and it is done. I am still learning c++. I will give it a try. That helped a lot.
Error 3 error C2614: 'SavingAccount' : illegal member initialization: 'BankAccount' is not a base or member c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\savingsaccount.h 18 1 Inheritance
Error 2 error C2504: 'BankAccount' : base class undefined c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\savingsaccount.h 7 1 Inheritance
Error 1 error C2011: 'BankAccount' : 'class' type redefinition c:\users\terry\documents\visual studio 2010\projects\inheritance\inheritance\bankaccount.h 8 1 Inheritance
I am going to see if I can figure this out before anyone can reply. But feel free to look it over, please. Thanks for your help.
// BankAccount.h
#ifndef BANKACCOUNT_H // Or pick some other unique identifier
#define BANKACCOUNT_H
class BankAccount
{
// etc.
};
#endif
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// CheckingAccount.h
#ifndef CHECKINGACCOUNT_H // Or pick a different name, doesn't really matter
#define CHECKINGACCOUNT_H
#include <iostream>
#include <iomanip>
#include <cmath>
#include "BankAccount.h" // Need this so the compiler can see BankAccount
class CheckingAccount: BankAccount
{
// etc.
};
#endif
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// SavingsAccount.h
#ifndef SAVINGSACCOUNT_H // Once again, you don't have to use this name...
#define SAVINGSACCOUNT_H
#include <iomanip>
#include <iostream>
#include <cmath>
#include "BankAccount.h" // So the compiler can see BankAccount
class SavingAccount : BankAccount
{
// etc.
};
#endif
Since you're using the Microsoft compiler, it'll also work if you just put #pragma once at the top of your header files instead, but be warned that this is a non-standard extension, so it won't necessarily work on all compilers.