Convert an object to a string? (C++)

Community Forums/General Help/Convert an object to a string? (C++)

JoshK(Posted 2010) [#1]
I want to do this:

Vec3 v;
Print( "Printing Vec3:" );
Print( v );

My Print() command takes a string.

I added an operator to the Vec3 class:
Vec3::operator string()
{
	char buf[1024];
	Print("calling string operator");
	sprintf(buf,"%f, %f, %f",x,y,z);
	return string(buf);
}

The compiler does not like this. What is the proper way to do this?


JoshK(Posted 2010) [#2]
I got it working. I just needed a clean build.


Canardian(Posted 2010) [#3]
I told you :P