I am having a hard time trying to run this excercise.

This works great up until the direction to declare the member functions

Once declaring romanType member functions protected:
class romanType

class romanType

void storeRomanInput(char RomanNum[25]);
void convertToDecimal(char storage[25]);
void printAsRoman();
void printAsDecimal();  

I am unable to run these functions from an object of the romanType class:

romanType use;

int _tmain(int argc, _TCHAR* argv[])
cout <<"Hello World!" << endl;
cout << "This is a utility that will convert a Roman numeral to decimal." << endl;
cout << "Please type your Roman Numeral: ";
cin >> UserInput;
use.storeRomanInput(UserInput); //these lines cause
use.convertToDecimal(storage);   //the error below


Error 2 error C2248: 'romanType::convertToDecimal' : cannot access protected member declared in class 'romanType'

5 Years
Discussion Span
Last Post by RonalBertogi

dear Daniel, if u make the methods 'protected' in your romanType class, then only the childern of romanType class will know that romanType class has some functions. so in this case, you must make them public, in order to interact with the outer world :)


hi!you should declare class member function as a public .so their accessibility should be global and recompile your porgram!if still problem then share program there i solve for you!thanks


All posts above are sufficient answers. I just want to add a little additional info regarding the protected statement: Data/properties and methods of a class declared as protected is only accessible to the class and its inheritors.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.