I'm going to try to keep this question within the student posting guidelines. I've been working on a class file, and I'm not sure I've constructed it correctly. I'm getting several errors concerning the function definitions and matching { with }. I've checked my brackets several times and it looks right to me. I've made changes, changed back, and I'm at a loss. I'm using Visual C++ Express 2005 on Windows Vista OS. It may just be something simple I'm overlooking.... and I'll feel stupid in the end lol. But I've been working on this for days and it's becoming a big blur. Any help would be appreciated.
Errors:
c:\users\sunni\ documents\visua l studio 2005\projects\s unnimortgagecal culatorr3\sunni mortgagecalcula torr3\menu.cpp( 31) : error C2660: 'Menu::validate ' : function does not take 2 arguments
c:\users\sunni\ documents\visua l studio 2005\projects\s unnimortgagecal culatorr3\sunni mortgagecalcula torr3\menu.cpp( 59) : error C2601: 'getInterestRat e' : local function definitions are illegal
c:\users\sunni\ documents\visua l studio 2005\projects\s unnimortgagecal culatorr3\sunni mortgagecalcula torr3\menu.cpp( 57): this line contains a '{' which has not yet been matched
c:\users\sunni\ documents\visua l studio 2005\projects\s unnimortgagecal culatorr3\sunni mortgagecalcula torr3\menu.cpp( 72) : error C2601: 'getTerm' : local function definitions are illegal
c:\users\sunni\ documents\visua l studio 2005\projects\s unnimortgagecal culatorr3\sunni mortgagecalcula torr3\menu.cpp( 57): this line contains a '{' which has not yet been matched
c:\users\sunni\ documents\visua l studio 2005\projects\s unnimortgagecal culatorr3\sunni mortgagecalcula torr3\menu.cpp( 100) : error C2660: 'Menu::validate ' : function does not take 2 arguments
The following is the header file, in case that's where I've made the mistake:
Code:
#include "stdafx.h"
#include <string>
#include <iostream>
#include <cstdlib> // to use system("cls") used to "clear screen"
#include <limits> // to declare numeric limits
using namespace std;
// class constructor
Menu::Menu(void)
{
}
// class destructor
Menu::~Menu(void)
{
}
int Menu::getOption() // function to prompt user for interest rate input
{
std::string reply;
// User prompted to enter interest rate
// Repeat until user enters a valid response
do{
system("cls");
cout << endl;
cout << endl << "Please choose a term and interest input option: ";
cout << endl << "\t\t1.) Enter your own term and interest values.";
cout << endl << "\t\t2.) Select from a list of term and interest options.";
cout << endl;
cout << endl << "Option selected: ";
cin >> reply;
if(validate(reply, "0123456789") == true)
{
cstr = reply.c_str();
menuChoice = atoi(cstr);
repeat = false;
if(menuChoice <= 0)
{
repeat = true;
callError();
}
else {
if(menuChoice >= 3)
{
repeat = true;
callError();
}
else {
repeat = false;
}
}
}
}while(repeat == true);
return menuChoice;
if (menuChoice == 1)
{
double getInterestRate() // function to prompt user for interest rate input
{
// initialize variables
double interestRate;
string reply;
// User prompted to enter interest rate
cout << endl;
cout << endl << "Please enter the interest rate (%): ";
cin >> interestRate;
return interestRate;
}
int getTerm() // function to prompt user for loan term input
{
// initialize variables
int term;
string reply;
// User prompted to enter loan term
cout << endl;
cout << endl << "Please enter the loan term (years): ";
cin >> term;
return term;
}
}
else{
if (menuChoice == 2)
{
do // do while loop to make menu selection
{
system("cls");
cout << endl;
cout << endl << "Please choose term and interest option: ";
cout << endl << "\t\t1.) 7 years at 5.35%";
cout << endl << "\t\t2.) 15 years at 5.50%";
cout << endl << "\t\t3.) 30 years at 5.75%";
cout << endl;
cout << endl << "Option selected: ";
getline(cin, reply);
if(validate(reply, "0123456789") == true)
{
cstr = reply.c_str();
option = atoi(cstr);
repeat = false;
if(option <= 0)
{
repeat = true;
callError();
}
else {
if(option >= 4)
{
repeat = true;
callError();
}
else {
repeat = false;
}
}
}
}while(repeat == true);
return option;
}
}
}
Errors:
c:\users\sunni\ documents\visua l studio 2005\projects\s unnimortgagecal culatorr3\sunni mortgagecalcula torr3\menu.cpp( 31) : error C2660: 'Menu::validate ' : function does not take 2 arguments
c:\users\sunni\ documents\visua l studio 2005\projects\s unnimortgagecal culatorr3\sunni mortgagecalcula torr3\menu.cpp( 59) : error C2601: 'getInterestRat e' : local function definitions are illegal
c:\users\sunni\ documents\visua l studio 2005\projects\s unnimortgagecal culatorr3\sunni mortgagecalcula torr3\menu.cpp( 57): this line contains a '{' which has not yet been matched
c:\users\sunni\ documents\visua l studio 2005\projects\s unnimortgagecal culatorr3\sunni mortgagecalcula torr3\menu.cpp( 72) : error C2601: 'getTerm' : local function definitions are illegal
c:\users\sunni\ documents\visua l studio 2005\projects\s unnimortgagecal culatorr3\sunni mortgagecalcula torr3\menu.cpp( 57): this line contains a '{' which has not yet been matched
c:\users\sunni\ documents\visua l studio 2005\projects\s unnimortgagecal culatorr3\sunni mortgagecalcula torr3\menu.cpp( 100) : error C2660: 'Menu::validate ' : function does not take 2 arguments
The following is the header file, in case that's where I've made the mistake:
Code:
class Menu
{
public:
// base constructor
Menu(void);
// base destructor
~Menu(void);
// base class methods
int option;
bool repeat;
int menuChoice;
int getOption();
double getInterestRate();
int getTerm();
bool validate();
const char *cstr;
bool loop(void);
void callError();
};
Comment