小编Ale*_*lex的帖子

构造函数问题(C++)

在我的"Portfolio"构造函数中,它认为我的调试器认为我正在尝试将返回类型设置为它.我不明白为什么.

#include <iostream>
#include <iomanip>

using namespace std;

class BankAccount
{
private:
int accountNum;
double accountBal;
double annualIntRate;
public:
BankAccount(int, double balance = 0.0, double rate = 0.0);
BankAccount();
void enterAccountData();
void computeInterest(int);
void displayAccount();
double getBalance();
};
 //implementation section:
BankAccount::BankAccount()
{
accountNum = 0;
accountBal = 0;
annualIntRate = 0;
}
BankAccount::BankAccount(int account, double balance, double rate)
{
const int LOWEST = 1000;
const int HIGHEST = 9999;

if(account < LOWEST || account > HIGHEST)
{
    accountNum = 0; …
Run Code Online (Sandbox Code Playgroud)

c++ constructor class visual-studio-2008

0
推荐指数
1
解决办法
272
查看次数

需要一些帮助来解决两个错误(C++)

我已经进行了一段时间的编码,这可能是一个容易的错误,我只是忽略了睡眠不足,但问题发生在这段代码.

do
{
    aWithIntAcct.enterAccountData();
    aWithIntAcct.getSavInfo();
    aWithIntAcct.getCheckingInfo();
    checkAcct.push_back(aWithIntAcct);
    cout << "Would you like to enter another Checking Account with interest? y or n ";
    cin >> quitChar;
}while(quitChar != QUIT);
Run Code Online (Sandbox Code Playgroud)

它说我有'enterAccountData'的模糊访问(错误C2385)这与其他(错误C3861)标识符没有找到相矛盾.

我的类是继承的,所以我不知道为什么这个为我工作.有什么建议?

其余代码:

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
template <class T>
void repeatValue(T val, int times)
{
for(int x = 0; x < times; x++)
{
    cout << "-";
}
};
template <class T>
void produceReport(int tableRows, string title, T acctType)
{
cout …
Run Code Online (Sandbox Code Playgroud)

c++ syntax templates class multiple-inheritance

0
推荐指数
1
解决办法
333
查看次数