Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Identifier not declared?

Reply
Thread Tools

Identifier not declared?

 
 
eli m
Guest
Posts: n/a
 
      03-11-2013
I am trying to call these two functions and it says identifier not declared.
My code is this:


#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <stdlib.h>
using namespace std;
int main() {
int run = 0;
string function, mathop;
int x, y;
cout << "Type in help for a list of functions\n";
//Start main loop
while (run == 0) {
cout << "Type in a function:";
cin >> function;
//Math function
if (function == "math") {
int mathloop;
mathloop = 0;
//Start while loop for math function
while (mathloop == 0) {
cout << "What math operation do you want to use?";
cin >> mathop;
// Multiplication Math Function
if (mathop == "multiplication") {
int mfirstnum, msecondnum;
float ans;
cout << "Type in your first number:";
cin >> mfirstnum;
cout << "Multiply your first number by:";
cin >> msecondnum;
ans = mfirstnum * msecondnum;
cout << ans << "\n"; }
//Break out of mathloop if main is entered
else if (mathop == "main") {
mathloop = 1; }
//Division Math function
else if (mathop == "division") {
int dfirstnum, dsecondnum;
float ans;
cout << "Type in your first number:";
cin >> dfirstnum;
cout << "Divide your first number by:";
cin >> dsecondnum;
ans = dfirstnum / dsecondnum;
cout << ans << "\n"; }
//Addition Math Function
else if (mathop == "addition") {
int afirstnum, asecondnum;
float ans;
cout << "Type in your first number:";
cin >> afirstnum;
cout << "Add your first number by:";
cin >> asecondnum;
ans = afirstnum + asecondnum;
cout << ans << "\n"; }
//Exponent Math Function
else if (mathop == "exponent") {
double efirstnum, esecondnum;
float ans;
cout << "Type in your first number:";
cin >> efirstnum;
cout << "Multiply your first number by the power of:";
cin >> esecondnum;
ans = pow(efirstnum,esecondnum);
cout << ans << "\n"; }
//Subtraction Math Function
else if (mathop == "subtraction") {
float ans;
cout << "Type in your first number:";
x = getIntx();
cout << "Subtract your first number by:";
y = getInty();
ans = x - y;
cout << ans << "\n"; }
//Catch Invalid Math Functions
else {
cout << "Not a valid math function" << "\n"; }
}
}
//Help Function
else if (function == "help") {
string line;
//Open File For Docs
ifstream myfile ("documentation.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}

else cout << "Unable to open file\n";
}
//Random Function
else if (function == "random") {
int randomloop = 0;
string randfunc;
while (randomloop == 0) {
cout << "Random function to use:";
cin >> randfunc;
//Random Number Function
if (randfunc == "number") {
int x, y, rnum;
cout << "Minimum number:";
x = getIntx();
cout << "Maximum number:";
y = getInty();
rnum = rand() % x + y;
cout << rnum << "\n"; }
//Break out of randomloop if main is entered
else if (randfunc == "main") {
randomloop = 1; }
//Catch invalid random functions
else {
cout << "Not a valid random function" << "\n"; }
}
}
}
}
//IIF
int getIntx(){
int x = 0;

while(!(cin >> x)){
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(),'\n') ;
cout << "Invalid input. Try again: ";
}

return x;
}


int getInty(){
int y = 0;

while(!(cin >> y)){
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(),'\n') ;
cout << "Invalid input. Try again: ";
}

return y;
}

Why is it saying identifier not declared for getIntx and getInty when i try to call them?
 
Reply With Quote
 
 
 
 
eli m
Guest
Posts: n/a
 
      03-12-2013
Nevermind, i figured it out.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSD Error: "Expecting '.', identifier or quoted identifier withmultiple tables. S_K ASP .Net 0 08-06-2008 09:22 PM
How can I fix the warning C4786 'identifier' : identifier wastruncated to 'number' characters in the debug information...? babakandme@yahoo.com C++ 2 12-11-2007 08:17 PM
identifier not found error, undeclared identifier aarthi28@gmail.com C++ 2 02-26-2007 02:11 AM
Trying to declare identifier locally and hide a file scope identifier Kobu C Programming 7 02-25-2005 05:19 AM
is not a valid identifier Marc Bishop ASP .Net 2 11-12-2003 10:23 PM



Advertisments