In my string class I have a constructor for type conversions from char * to string (the name of my string class). My program doesn't implicitly convert char * to string when I say something like
Code:
string test;
test = "foo";
I get an illegal operand error if I try something like that.
My constructor works fine if I say
Code:
string test = "foo";
Does anybody know why this is?
Here's my code, it will probably help:
Code:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

	class string
	{
	protected:
		char * str;
		unsigned int len;
		unsigned int strlen(char *);
	public:
		string() : len(0), str(0) {}
		string(char *);
		string & operator=(string &);
	};
	unsigned int string::strlen(char * s)
	{
		unsigned int a = 0;
		while (s[a] != '\0')
			a++;
		return a;
	}
	string::string(char * s)
	{
		unsigned int slen;
		len = slen = strlen(s);
		str = new char[slen];
		for(unsigned int a = 0; a < slen; a++)
			str[a] = s[a];
	}
	string & string::operator=(string & s)
	{
		delete [] this->str;
		this->str = new char[s.len];
		this->len = s.len;
		for(unsigned int a = 0; a < s.len; a++)
			this->str[a] = s.str[a];
	}

int main()
{
	string test;
	test = "beef lo mein";
	return 0;
}