Can't Create Static or Const Data Members

I have tried reading different descriptions of how the declarations of these variables are made and how they operate, but they don't seem at all clear to me. According to how I interpreted the tutorial what I have below should not result in an error, yet it does. Can somebody please tell me what I am doing wrong? Thanks.

I realize that don't have an entire program here. My job for now is to build a class that meets certain specifications.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  #include <iostream>
using namespace std;

int main(){
    
    class Rectangle{
        
        
    public:
        static const int maxRectangles; // Static data member not allowed in local class
        static int rectanglesCreated; // Static data member not allowed in local class
        static double avgPerimeter, avgArea; // Static data member not allowed in local class
        void calculatePerimeter();
        void calculateArea();
        
        
        
    private:
        double length, width;
        char border_character, fillCharacter;
        
        const int MAX, MIN;
        
    }
    return 0;
}
Last edited on
I figured out my mistake. I carelessly defined my class within main.
Topic archived. No new replies allowed.