Why the "{" In this piece of code needed

after the declaration of the main function wi see "{" why is needed?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// classes example
#include <iostream>
using namespace std;

class CRectangle {
    int x, y;
  public:
    void set_values (int,int);
    int area () {return (x*y);}
};

void CRectangle::set_values (int a, int b) {
  x = a;
  y = b;
}

int main () {
  CRectangle rect;
  rect.set_values (3,4);
  cout << "area: " << rect.area();
  return 0;
}
Last edited on
What makes you think it shouldn't be there?
due to my lake of expierience i have hard time to understand why it should be there...
pls notice that there is no "}" only "{" i mean this symbol doesnt represent range of values
of some type?
Last edited on
The function body starts with a { (line 17) and ends with a } (line 22).
Last edited on
im sry i just got used to that int main has "{" after new line lol
Last edited on
Topic archived. No new replies allowed.