undeclared identifier

So basically i have this class
when i try to use it in my function 'convertArabictoRoman'
it says that the variable 'thous' is undeclared
Looked it over soooo many times and i still cant figure out why its not reading it?????


//romanType Class
class romanType
{
public:
//Public functions
romanType();//Constructor
void getArabicNumber();//reads in arabic number
void getRomanNumeral();//reads in roman numeral
void convertArabictoRoman();//converts number from arabic to roman (*Not working*)
private:
//private members
int arabnum,thous;//arabic number
char romannum[50];//array for roman numeral

};






//simplified implementation file
#include "romanType.h"
#include <iostream>
using namespace std;

//Constructor for 'romanType' class
romanType::romanType()
{
arabnum=0;
thous=0;

}

void romanType::convertArabictoRoman()
{

int thous= arabnum/1000;
cout << thous;


}
It happened because a compiler doesn't know what is "thous"?

There are two definitions of "thous".
The first is situated inside the class romanType, the second in the convertArabictoRoman method.

As I think you want to do the following:
1
2
3
4
5
void romanType::convertArabictoRoman()
{
    thous= arabnum/1000; //You don't need declare thous, because it is declared already
    cout << thous;
}
the thing is that in the 'convertArabictoRoman()' function im not declaring it again
it turns out (which i dont know why) the problem got fixed after i deleted my .h file and re made it
for some reason the compiler accepted that one and it now works just fine

thanks for the help though
:]
Topic archived. No new replies allowed.