incompatible types in assignment of 'char*'
I am trying to compile program given in link C++/Classes and Inheritance - Wikiversity but it gives error
Code:
#include<iostream>
class Dog
{
private:
char name[25];
int gender;
int age;
int size;
bool healthy;
public:
char* getName() { return name; }
int getGender() { return gender; }
int getAge() { return age; }
int getSize() { return size; }
bool isHealthy() { return healthy; }
void setHealthy(bool dhealthy) { healthy = dhealthy; }
void setName(char* dname) { name = dname; }
};
int main()
{
Dog lucy;
std::cout << "lucy's name is " << lucy.getName() << std::endl;
std::cout << "lucy's gender is " << lucy.getGender() << std::endl;
std::cout << "lucy's age is " << lucy.getAge() << std::endl;
std::cout << "lucy's size is " << lucy.getSize() << std::endl;
if(lucy.isHealthy())
std::cout << "lucy is healthy" << std::endl;
else
std::cout << "lucy isn't healthy :(" << std::endl;
std::cout << "Now I'm changing lucy abit..." << std::endl;
lucy.setHealthy(!(lucy.isHealthy()));
lucy.setName("lUCY");
std::cout << "lucy's name is " << lucy.getName() << std::endl;
std::cout << "lucy's gender is " << lucy.getGender() << std::endl;
std::cout << "lucy's age is " << lucy.getAge() << std::endl;
std::cout << "lucy's size is " << lucy.getSize() << std::endl;
if(lucy.isHealthy())
std::cout << "lucy is healthy" << std::endl;
else
std::cout << "lucy isn't healthy :(" << std::endl;
return 0;
}
In member function 'void Dog::setName(char*)':
error: incompatible types in assignment of 'char*' to 'char [25]'
void setName(char* dname) { name = dname; }
^~~~~
In function 'int main()':
warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
lucy.setName("lUCY");
^