Error invalid conversion from `char' to `const char*'

I have this following code and Error invalid conversion from 'char' to 'const char*' occurs.
I have created a header file and the other one is the main file(source file.)
header file is:


using namespace std;
class romanType
{
public:
void romanNum();
void decimalNum();
void print();
romanType(string = '*', int = 0);
~romanType();

private:
string roman;
int decimal;
};

void romanType::romanNum()
{
cout<<"Please enter the number in Roman: ";
cin>>roman;
}

void romanType::decimalNum()
{
short size;
size = roman.size();
for(int i=0; i<=size; i++)
switch(roman[i])
{
case'M': decimal += 1000;
case'D': decimal += 500;
case'C': decimal += 100;
case'L': decimal += 50;
case'X': decimal += 10;
case'V': decimal += 5;
case'I': decimal += 1;
default: decimal += 0;
}
}

void romanType::print()
{
short i;
cout<<"Please enter 0 to print Roman number"
<<" or 1 to print corresponding decimal number.";
cin>>i;
if(i)
cout<<"Decimal number is: "<<decimal<<endl;
else if(!i)
cout<<"Roman number is: "<<roman<<endl;
else
{
cout<<"Invalid entry please renter the number."<<endl;
print();
}
}

romanType::romanType(string a, int b)
{
roman = '*';
decimal = 0;
}


// and main file is

#include<iostream>
#include"romanType.h"
using namespace std;
int main()
{
romanType number; //This line gives error.
number.romanNum();
number.decimalNum();
number.print();

system("pause");
}


//when I run this prgram the error occurs Invalid conversion from 'char' to 'const char*'. Please help main
Last edited on
string = '*' should be string = "*"
That said, that entire line doesn't make much sense. What are you trying to do with it?

This ~romanType(); is a promise to the compiler that YOU will write the destructor. Where is it?

Last edited on
I got it it's working now. Thanks all. Thank you again.
Topic archived. No new replies allowed.