gamblor01
06-14-2005, 11:57 AM
Can anyone offer some advice why the following code won't compile? I have an unsigned int array (a) and I'm trying to take a[1], and convert it to a string using std::stringstream. Here's just a code snippet:
a[1] = convertToUnsInt(input) + convertToUnsInt(revInput);
/* now put the integer value in a[1] back into char* input */
std::stringstream myStream;
myStream << a[1];
myStream >> input;
Everytime I compile however, I get an error on the line "std::stringstream myStream" that says the following:
error: aggregate `std::stringstream myStream' has incomplete type and cannot be defined
WHAT?!?!?! What on earth does that mean? I'm a Java head, so I'm used to using Integer.parseInt() to do my conversions for me, and then making an integer a string is as easy as concatenating!...
String myStr = "" + someInt;
Not so easy in C++. I would use atoi but it returns an int, and I may be dealing with a value that's too large for int (they're unsigned values) so I had to write my own function to convert that DOES return an unsigned int. Now I can't get that int back to a string.
a[1] = convertToUnsInt(input) + convertToUnsInt(revInput);
/* now put the integer value in a[1] back into char* input */
std::stringstream myStream;
myStream << a[1];
myStream >> input;
Everytime I compile however, I get an error on the line "std::stringstream myStream" that says the following:
error: aggregate `std::stringstream myStream' has incomplete type and cannot be defined
WHAT?!?!?! What on earth does that mean? I'm a Java head, so I'm used to using Integer.parseInt() to do my conversions for me, and then making an integer a string is as easy as concatenating!...
String myStr = "" + someInt;
Not so easy in C++. I would use atoi but it returns an int, and I may be dealing with a value that's too large for int (they're unsigned values) so I had to write my own function to convert that DOES return an unsigned int. Now I can't get that int back to a string.