Problem getting the constructor to work

When I try to get this to work, it keeps saying vectorA was not declared in this scope?

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

#include <iostream>
#include <cstdlib>
#include <time.h>
#include <vector>
#include <ctime>
#include <algorithm>

using namespace std;

class randomClass
{
    public:
        randomClass()
        {
            vector<int> vectorA(4);

            bool boolVectorA = false;

            srand(time(0));
        }
        void intro()
        {
            cout << "Random number 1 to 20: ";
        }

        void randomizeVectors()
        {
            for(int i=0;i<5;i++)
            {
                vectorA[i] = rand() % 20 + 1;
            }
        }
        
        void printVectors
        {
            for(int i=0;i<5;i++)
            {
                cout << vectorA[i];
            }
        }
};


int main()
{
    randomClass a;
    a.intro;
    a.randomizeVector
    a.printVectors;
}
You should be declaring member variables outside of any functions. Usually under" private:"
Topic archived. No new replies allowed.