I'm getting 8 errors in this program. Can anyone help?
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
class Name {
const char* m_value;
void allocateAndCopy(const char* value) {
delete[] m_value;
m_value = new char[strlen(value) + 1];
strcpy(m_value, value);
}
public:
Name() :m_value(nullptr) {
};
Name(const char* value) :m_value(nullptr) {
allocateAndCopy(value);
}
Name(Name& N) {
*this = N;
}
Name operator=(const Name& N) {
allocateAndCopy(N.m_value);
return this;
}
~Name() {
delete[] m_value;
}
void display(ostream& os)const {
os << m_value;
}
void read(istream& is) {
char val[1000];
getline(is, val);
allocateAndCopy(val.c_str());
}
};
ostream& operator<<(ostream& os, Name& N) {
N.display(os);
return os;
}
istream& operator<<(istream& is, Name& N) {
return N.read(is);
}
The errors I'm getting are:
Severity Code Description Project File Line Suppression State
Error (active) E0167 argument of type "const char *" is incompatible with parameter of type "char *"
and more.