CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2013
    Posts
    3

    error C2059: syntax error : '->'

    Hi

    So im a bit lost in my c++ programming. Not the code init self, but a error I keep getting. I dont know why I keep getting -> error?

    Im using Visual Studio ultimate 2010, and I havnt had any problem with it, til now:
    Does anyone know why I keep gettin this error or possibly can be written some other way?


    Error 1 error C2059: syntax error : '->'

    Greatly appreciated!

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: error C2059: syntax error : '->'

    http://msdn.microsoft.com/en-us/libr...(v=vs.90).aspx
    https://www.google.com/search?q=erro...'&start=10

    If you need more "specific" reply - post your code that causes such an error.
    Victor Nijegorodov

  3. #3
    Join Date
    Aug 2013
    Posts
    3

    Re: error C2059: syntax error : '->'

    Thanks, but Ive gone through all those, I couldnt find anything on www. This is my only option.

    I need help with this error: Error 1 error C2059: syntax error : '->'

    Am i typing -> wrong? Or does Visual Studio ultimate 2010 use some other way?

    Thanks in advance

  4. #4
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: error C2059: syntax error : '->'

    Quote Originally Posted by Maygon View Post
    Thanks, but Ive gone through all those, I couldnt find anything on www. This is my only option.

    I need help with this error: Error 1 error C2059: syntax error : '->'

    Am i typing -> wrong? Or does Visual Studio ultimate 2010 use some other way?

    Didn't you read my answer?
    Quote Originally Posted by VictorN View Post
    http://msdn.microsoft.com/en-us/libr...(v=vs.90).aspx
    https://www.google.com/search?q=erro...'&start=10

    If you need more "specific" reply - post your code that causes such an error.
    and, please, use Code tags when you you will post any code snippets!
    Victor Nijegorodov

  5. #5
    Join Date
    Aug 2013
    Posts
    3

    Re: error C2059: syntax error : '->'

    I need someone to help me with this error of mine.
    http://speedy.sh/kEjM3/Syntax-error.png

    I dont need help with any coding, just an explanation of why this might be happening.

    Quite frustrating because i´ve never had any problems writting....... ->.......in any codes of c++ softwares that ive used like codeblocks or dev c++.

    Thanks again

  6. #6
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: error C2059: syntax error : '->'

    Sh,,,t!
    If you do need some help - show the code causing the problem, not the link to something that does not belong to this Forum.
    Besides, it is not clear what symbols and from what code page do you use in "->" expression. So, again: post your exact code (use copy/paste, not just typing it in the edit window)
    Last edited by VictorN; August 24th, 2013 at 09:26 AM.
    Victor Nijegorodov

  7. #7
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: error C2059: syntax error : '->'

    Quote Originally Posted by Maygon View Post
    I need someone to help me with this error of mine.
    http://speedy.sh/kEjM3/Syntax-error.png

    I dont need help with any coding, just an explanation of why this might be happening.

    Quite frustrating because i´ve never had any problems writting....... ->.......in any codes of c++ softwares that ive used like codeblocks or dev c++.

    Thanks again
    Good grief dude, how do you expect anybody to tell you what you're doing wrong if you don't show us what you're doing?!?

  8. #8
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: error C2059: syntax error : '->'

    I dont need help with any coding, just an explanation of why this might be happening.
    In your program, you are using -> in a context for which the compiler does not accept -> as a valid symbol.

    If the line containing the -> is supposed to be used correctly but the compiler is reporting a problem, I would look at the code before the line reporting the error for problems - or with the variable definition.

    As others have pointed out, to provide further specific guidance you need to post the code containing the error line.
    Last edited by 2kaud; August 24th, 2013 at 10:46 AM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  9. #9
    Join Date
    Apr 1999
    Posts
    27,449

    Re: error C2059: syntax error : '->'

    Quote Originally Posted by Maygon View Post
    I dont need help with any coding, just an explanation of why this might be happening.
    It is happening because you're using -> where it shouldn't be used.
    Quite frustrating because i´ve never had any problems writting....... ->.......in any codes of c++ softwares that ive used like codeblocks or dev c++.
    C++ is a computer language that has rules. It isn't a book report where you just "write stuff", and it has nothing to do with codeblocks or dev-C++. Your code violates a C++ rule in some way, and the only way to know is to see the code.

    Regards,

    Paul McKenzie

  10. #10
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: error C2059: syntax error : '->'

    Quote Originally Posted by Maygon View Post
    I dont need help with any coding, just an explanation of why this might be happening.
    Just an explanation of why: Compiler Error C2059

    In two words, you put token -> where it does not belong.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured