Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

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?

Update:

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... the * operation "Returns a reference to the value pointed by the auto_ptr object."

1 Answer

Relevance
  • oops
    Lv 6
    1 decade ago
    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_;

Still have questions? Get your answers by asking now.