Having a strange problem making a new string class and assigning an array of char*
to it in the GCC compiler. Source code:
#include "../Include/StdString.h"
StdString::StdString()
{
//ctor
internstr = std::string();
}
char* StdString::operator=(StdString other) {
return other.cstr();
}
StdString StdString::operator+(StdString other) {
StdString newstr = StdString();
newstr.internstr = internstr+other.internstr;
return newstr;
}
void StdString::operator=(char* other) {
internstr = other;
}
StdString::~StdString()
{
//dtor
}
char* StdString::cstr() {
return (char*)internstr.c_str();
}
Error: conversion from char*
to non-scalar type StdString
requested.
How did std::string
do their assignments?