Questions tagged [curly-braces]

The symbols "{" and "}", commonly used in programming languages. Please use this tag only if the specific usage of these symbols is a relevant part of the question.

The symbols "{" and "}", commonly used in programming languages. Please be sure that the specific usage of these symbols is a relevant part of the question.

652 questions
-4
votes
1 answer

Curly Brace expected error? How do I fix it?

I have looked through other questions after Visual Studio gave me error CS1513, saying it's expecting a curly bracket, where I already have a curly bracket. https://i.stack.imgur.com/MGlQ3.jpg
Arctech
  • 1
  • 1
-5
votes
1 answer

Why can we write a for loop without Curly Brackets in methods out of main function

enter image description here Why can we write a for loop without Curly Brackets in methods out of main function
-6
votes
2 answers

What is the scope of a for loop without braces in C++

I understand that {...} introduces a new scope, which is why the following would not work: for(int i = 0; i < 10; i++) { // Do something... } cout << i << endl; // Error: i is not defined in this scope However, I'm getting the same error when…
-6
votes
1 answer

Code fails when class definition closed

I'm a beginner to Java trying to understand why my program works when it seems like it shouldn't. When I try and compile the code below, I get the error "class, interface, or enum expected" and it points to the brace on the final line of the…
fauxfaux
  • 1
  • 1
-12
votes
1 answer

Where should we put the opening brace of a class in 1TBS style?

I have read the Indentation style entry on Wikipedia, but it's not very clear. For K&R style, it says: each function has its opening brace at the next line on the same indentation level as its header Multi-line blocks inside a function, however,…
Míng
  • 2,500
  • 6
  • 32
  • 48
1 2 3
43
44