I compiled very simple code, but I couldn't compile this code.
#include <iostream>
using namespace std;
class String {
char *str;
public:
String(char *);
~String();
char *get() { return str; }
};
String::String(char *p)
{
cout << " ! constructor\n";
str = new char[strlen(p) + 1];
strcpy(str, p);
}
String::~String()
{
cout << " ! destructor\n";
delete str;
}
void show1(String &s)
{
cout << "show1 : " << s.get();
}
void show2(String s)
{
cout << "show2 : " << s.get();
}
int main()
{
char *str = "C++ Language";
String ss(str);
show1(ss); cout << endl;
show2(ss); cout << endl;
return 0;
}
error say it can't be converted const char [13] to char * . how can I compile this code? I compile this with visual studio.