#pragma once
#include <string>
usingnamespace System;
usingnamespace std;
class CreditCard
{
public:
CreditCard();
CreditCard(int bc);
double getCredLimit();
double getBalDue();
int getAccNum();
double credAvailable();
int incre_Credit();
void trans1();
int cdInc();
bool addingChrg(double chrgAmt, const std::string& desc);
~CreditCard();
private:
int accNo;
bool err;
string mssg;
double lim;
double dueAmt;
void wtStats();
void logFl(string qu);
string credName, credlastName;
double bala = lim; // this is the line I am getting 3 errors
double payscale;
double chrg;
};
The errors are
error C2327: 'CreditCard::lim' : is not a type name, static, or enumerator
error C2065: 'lim' : undeclared identifier
error C2864: 'CreditCard::bala' : only staticconst integral data members can be initialized within a class
What am I doing wrong?
assign that in the constructor of the class. You can't assign this way at this point. Also, lim has no value at this point in the code anyway, so it would be copying junk to junk .
think of it this way:
a class is a type. so double lim; inside your class DOES NOT EXIST yet. It only exists when you make an object of the class type: creditcard cc; //creates instance of the class, bringing cc.lim into existence.
To be more precise, lines 10 and 11 declare the constructors. The actual definitions of those constructors are, presumably, in the cpp file along with the rest of the method definitions.