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
{
protected:

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'

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 article has been dead for over six months. Start a new discussion instead.