generating random numbers in an array

i'm trying to to generate random numbers in an array, up to 100 numbers, using classes and objects. so far, i have:
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
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <new>
#include <stdio.h>

using namespace std;

class ArrayClass1 {
    private: 
		int *array;
		int size;
			
    public: 
		ArrayClass(int size){
			array = new int[size];	
			srand((unsigned)time(NULL));
			array[size] = (rand() % 100) +1;
		}
		print(void){
			printf("%6d\n" , array[size]);
		}

			
};

int main() { 
	
	ArrayClass1 theArray;

    theArray.ArrayClass(100); 
    theArray.print();

}


the problem is i get this error for line 15 and 20:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

just wondering if i can get some feedback for this problem, thanks.
Your class is named ArrayClass1 but your constructor is named ArrayClass. And your print function needs to have a return type, presumably void. There are many logic errors in your program as well. For instance you are accessing the array with size, but that is the size of the array, which is out-of-bounds as an index.
Topic archived. No new replies allowed.