#include <iostream>
#include <iomanip>
usingnamespace std;
class Business
{
char name;
public:
Business(char name) {Business::name=name;}
void showBusiness();
};
void::Business::showBusiness (){
cout<<"Name: "<<name<<".\n\n";
}
int main()
{
int name;
cout<<"Enter the name of the business: ";
cin>>name;
cout<<endl<<endl;
Business bus(name);
bus.showBusiness ();
return(0);
}
On line 7 name is a char. On line 22 the variable is an int.
Edit in italics:
When you run the code using the gear icon at the top right, it displays the character that corresponds with the ASCII code of whatever number you enter, unless that number is bigger than what a char handle.
Char isn't a good type for a name, perhaps you need std::string?
Thank you for your help. What is the easiest way to input into std::string name?
(When I switched the int name to char name in line 22 the program only displays the first letter of the name entered.)