I'm not quite sure I understand what your program is supposed to do. What is the purpose of this program?

In your private data, int i and string x don't seem to have a purpose, they can go.

Your statement:
Code:
if ( length =! 4 )
won't work, it needs to be:
Code:
if(length != 4)
declaring an "int length" in main is uneccessary as you can rewrite your if statement like this:
Code:
if(newvalue.length() != 4)
also the for loop in code(string newvalue) loops one too many times. If you're trying to process the 4 chars of the string your loop only needs to run 4 times:
Code:
for(int i = 0; i < 4; i++)
because "i" in this case is initialized at 0. Which means the loop will execute at:
0, 1, 2, and 3 (which is 4 times through)

Other than that, like I said, I don't know the purpose of your program, so I can't help you beyond which you've got here.