Const pointer problem?

I am getting an error that my pointer is a const. I'm not sure why, as I don't (Purposefully) use consts anywhere in my code.

Class
1
2
3
4
5
6
7
8
9
	private:
		char* s_ptr;
	public:
	
	myString(char* char_ptr) //Works perfectly
	{
		s_ptr = (char*) malloc(strlen(char_ptr));
		//etc
	}


Friend
1
2
	free(s.s_ptr);
	s.s_ptr = (char*) malloc(strlen(input)); //C2166: l-value specifies const object 


I'm sure it's just something I'm not quite aware of. What seems to be the problem here?
I'm not sure why, as I don't (Purposefully) use consts anywhere in my code.

What a shame. For me, const-correctness prevents ca. 20% of all errors.

It seems to be a wrong argument passing technique in the function you marked as "friend". Show us the declaration of this function (or the method it accesses 's').
Topic archived. No new replies allowed.