This is my first time using classes and I'm writing a simple program that will take a certain roman numeral and print out the numerical equivalent. However, I'm struggling to code my user input, my cin >> romanObject.getRomanNumeral(); isn't working. I get error E0349 saying no operator ">>" matches these operands. However, when I used just a simple char variable declared in my main function instead it worked fine. Why doesn't my variable in my class work?
#include <iostream>
#include <string>
using namespace std;
class romanType {
public:
void setRomanNumeral(string x) {
romanNumeral = x;
}
string getRomanNumeral() {
return romanNumeral;
}
private:
string romanNumeral;
};
void store();
int main()
{
store();
return 0;
}
void store() // Takes user input.
{
romanType romanObject;
romanObject.setRomanNumeral("Blank");
cout << "Enter one of the following roman numerals" << endl;
cout << "I, V, X, L, C, D, M." << endl;
cin >> romanObject.getRomanNumeral();
}