How does a semicolon cause a syntax error?

This is the error:

array.cpp(49): error C2059: syntax error : ';'

And this is the line of code it came from:

reg = s.default_value_*;

When I put parentheses around the default_value_* part, I get

syntax error : '('

instead. Any ideas?

2011-04-03T15:01:20Z

default_value_ is an std::auto_ptr and I am trying to assign the value of its object to reg, a variable. according to http://www.cplusplus.com/reference/std/memory/auto_ptr/operator*/, the * operation "Returns a reference to the value pointed by the auto_ptr object."

oops2011-04-03T14:54:22Z

Favorite Answer

A semi-colon is used to complete a statement, and this:

    reg = s.default_value_*;

is an incomplete statement.

What exactly are you trying to do there?

Edit:
operator*, when used as a unary operator, is a prefix operator.

    reg = *s.default_value_;