I have an assignment to write a program that allows you to input either arabic or mayan numbers and convert them to each other. we are supposed to use a class containing all of the functions and variables. lucky for me my teacher from my previous class neglected to teach us classes so I am sort of learning them as I go along. So far everything seemed to work ok until I tried to write the function that outputs the mayan number. I have the mayan number stored in a char array. In my output function it compiles with a warning and I get an error when I run the program. But when I cout the array in the same function as I inputted it everything works out just fine. Any information would be great, Thanks!
My class.
Code:
class MayanNumberType
{
public:
int GetArabicNumber();
void GetMayanNumber();
void ConvertToArabic();
void ConvertToMayan();
void PrintArabicNumber();
void PrintMayanNumber();
char MayanNumber[50];
int ArabicNumber;
};
This is my input function.
Code:
void MayanNumberType::GetMayanNumber()
{
MayanNumberType x;
cout << "Please enter the Mayan Number: ";
cin.ignore();
cin.getline(x.MayanNumber, 50);
}
This is my Output function. I am just outputting the first value in the array until I get it working.
Code:
void MayanNumberType::PrintMayanNumber()
{
MayanNumberType x;
cout << x.MayanNumber[0];
}