Array Classes

Have to make a code where I input array size and set array value to each member of array then print out the array. The code works but i'm not sure why its crashing after the code is run. It gives me a (11db) green error looking message. Can anyone explain why and help me out? Thanks!



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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
  #include <iostream>


using namespace std;

class myArrayClass
{
public:
    
    myArrayClass(){ /*constructor function*/ arraySize = 0; *ptrArray = NULL; looper = 1; }
    
    myArrayClass(int x)
        {
            arraySize = x; myArray[x];
        
            if (ptrArray == NULL)
                {
                    
                }
        }
    
    
    void setMyArraySize(int x)
        {
            cout << "Enter desired array size: ";
            
            for (int z = 0; z<looper; z++) {
            cin >> x;
            if (x>0)
            {
                arraySize = x;
                myArray[x];
            }else{
                cout << "Please input value greater than 0. \n\n";
                z--;
            }
            }
        }
    void printMyArrayClassSize() { cout << arraySize; }
    
    void set_Elements_Of_Array(int y)
        {
        
                for (int i = 0; i<= arraySize; i++)
            {
                cout << "Enter " << i << " element of array: " <<endl<< endl;
                cin >> myArray[i];
            }
            
        }
    void printMyArrayNumbers()
        {
            for (int l = 0; l<=arraySize; l++)
            {
                cout << l << " Element of array is: " << myArray[l] <<endl;
            }
        }
    

private:
    int looper = 1;
    int ArrayElement;
    int *ptrArray;
    int arraySize;
    double myArray[];
    
};


int main()
{
    //DECLARE INSTANCE OF A CLASS WITH TWO PARTS
    myArrayClass K1;
    myArrayClass K2(10); // <--- PARM Function Array
    
    //PARM FUNCTION
    cout << "Parameterized array size is: ";
    K2.printMyArrayClassSize();
    cout << " \n\n";
    
   
    
    //Declare local variable to use for PARM
    int x = 0;
    
    
    K1.setMyArraySize(x);
    
    cout << "Desired array size is: ";
    K1.printMyArrayClassSize();
    cout << " \n\n";
    
    
    int y = 0;
    
    
    K1.set_Elements_Of_Array(y);
    
    K1.printMyArrayNumbers();

}
http://www.cplusplus.com/forum/general/112111/

double myArray[]; illegal
myArray[x]; statement has no effect
Thank you. Figured it out!
Topic archived. No new replies allowed.