how can i put an array in a class the right way?

I am struggling on how to put an array in a class and call the array in main .I have tried but i get this error :

[Error] invalid conversion from 'int' to 'int*' [-fpermissive]


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
  		#include <iostream>  									// includes cin cout
		#include <cmath>     									// includes math function pow sqrt ect.
		#include<iomanip>    									// includes setw set precision 
		#include <stdlib.h>  									// includes rand
		#include <ctime>     									// includes time
// setting up the environment
     using namespace std; 								

const int numberOfStudents = 200; 


struct StudentsInfo {
  int id_number;
  int score;

};

class Course 
{
	public:
		void setSudentsClass (int allOfStudents[])
		{
			studentsClass[numberOfStudents] = allOfStudents[numberOfStudents];
		}
 		int getStudentsClass()
		 {
		 	return studentsClass[numberOfStudents];
		 }
	
private:
	
	int studentsClass[numberOfStudents];	  



};



int main ()
{

	 Course HeyWorld;
	 HeyWorld.setSudentsClass(  /* What can i put here ?*/ ); 
// this is where I geT the ERROR

// what can i put in the parameters to acces the array in my class?	

	  cout << getStudentClass();
 
   
   
}

void selectionSort(int a[ ], int n) 
{
	int i, k, indexOfNextSmallest, temp;
	for (i = 0; i < n - 1; i++)
	{
		indexOfNextSmallest = i;
		for (k=i+1; k<n; k++)
		if (a[k] < a[indexOfNextSmallest])
		indexOfNextSmallest = k;
		temp = a[i];
		a[i] = a[indexOfNextSmallest];
		a[indexOfNextSmallest] = temp;
	}
}
int Score(int allStudents[numberOfStudents] )											
{ 
 	/* Here I dont know if i did this right but i want to give the array 
 in my class to set the value equal to the structure so that each student 
has two variables to them . The students are given a random id number 
thats from 1 - 500   and a score that is  1 - 100. Can some one tell me 
if i did this righ and how would i put this function in my class?  */


        srand(time(NULL));  						

	for (int i = 0;i < numberOfStudents; ++i )													
	{		
  		 Course  StudentsTakingCourse;
		 StudentsInfo  InfomationForStudents;
		 InfomationForStudents.id_number = rand()%500 + 1;
   		 InfomationForStudents.score = rand()%100 + 1;       
		 StudentsTakingCourse.studentsClass[i] = InfomationForStudents.id_number;
		 StudentsTakingCourse.studentsClass[i] = InfomationForStudents.score;
	} 	
	
}

Last edited on
Topic archived. No new replies allowed.