Jump to content

C++ syntax error?

- - - - -

  • Please log in to reply
10 replies to this topic

#1
DMK741

DMK741

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
Hello everyone, and happy new year!


I'm trying to code my own version of Tetris using unmanaged C++, and it has been going ok so far, but my project will now not compile because of some odd syntax error. When trying to initialize my arrays in the Shape.h file, every left curly bracket gives an error.

I have hosted the Visual Studio 2010 project here: Tetris.7z

Thank you for any help. This is probably a simple mistake, as I am new to C++.

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Try getting rid of the dereferencing asterisks.
sudo rm -rf /

#3
DMK741

DMK741

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
didn't work.

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
I can't really test it right now, but try doing the entire thing in one assignment. There shouldn't be any need for dereferencing or indexing.
sudo rm -rf /

#5
DMK741

DMK741

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
Why no dereference operators? My variable is of type "pointer", so don't I need to have an asterisk before it if I assign a value to the memory it points to? And since it's a pointer to a pointer to a pointer, don't I need 2 asterisks (considering that I have "[]" which is really just a dereference operator with a shift)?

btw, I tried it anyway and it still gave me errors.

Edited by DMK741, 03 January 2011 - 10:26 PM.


#6
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
This works:

int chachacha[][2][4] = {{{1,2,3,4}, {5,6,7,8}}, {{9,10,11,12},{13,14,15,16}}};


sudo rm -rf /

#7
DMK741

DMK741

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts

dargueta said:

This works:

int chachacha[][2][4] = {{{1,2,3,4}, {5,6,7,8}}, {{9,10,11,12},{13,14,15,16}}};


no it doesn't. I get the same error, along with a new one for not having an index in that first set of brackets.

#8
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
It compiles just fine with GCC. What compiler are you using?
sudo rm -rf /

#9
DMK741

DMK741

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
Visual Studio is my IDE. idk what the name of the compiler is.

Try messing with pointer arrays like I did. See if you can get anything useful out of that.

#10
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Okay, but it'll have to wait until tomorrow night for me. Not sure about the time difference, though.
sudo rm -rf /

#11
DMK741

DMK741

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
that's ok. I appreciate it.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users