I am trying to write a program to convert a roman numeral to decimal. If I define a variable with: char roman_num[15];
can I then select individual characters in that roman numeral with: roman=roman_num[i];
where "i" is a number value of the character I want to retrieve from 0-14?
Also, I am getting an error when I try to compile my implementation file (my header file compiles fine). I can't locate my mistake...
Here are my compiler errors:
romanTypeImp.cpp: In function `int main()':
romanTypeImp.cpp:15: error: `romanToDecimal' undeclared (first use this function)
romanTypeImp.cpp:15: error: (Each undeclared identifier is reported only once for each function it appears in.)
I am using cygwin on XP and gcc (compiling with g++):
gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
Here is my header file:
class romanType
{
public:
romanType();
// Default constructor
void romanToDecimal(char roman);
// Convert from roman numeral to decimal
void printRoman();
// Print roman numeral
void printDecimal();
// Print decimal value
private:
char roman; // Store a single roman numeral
int decimal; // Store decimal value
char roman_num[15]; // Store roman numeral array of 15 characters
int numberM; // Store value of roman numeral M
int numberD; // Store value of roman numeral D
int numberC; // Store value of roman numeral C
int numberL; // Store value of roman numeral L
int numberX; // Store value of roman numeral X
int numberV; // Store value of roman numeral V
int numberI; // Store value of roman numeral I
};
Here is my implementation file:
#include <iostream>
#include "romanType.h"
using namespace std;
char roman;
void romanType::romanToDecimal(char roman)
{
cout<<"Testing"<<roman;
}
int main()
{
cout<<endl<<"Enter a Roman Numeral: ";
romanToDecimal('M');
}