|
-
December 15th, 2008, 01:10 AM
#1
noob needs help
hi i am trying to test a copy constructor but when i create an object from my class the compiler tells me that there is no default constructor but there is one !!!! here is my code
#include <iostream>
using namespace std;
class Rollsheet {
public:
Rollsheet (int num) {
numStudents = num;
scores = new int[num];
}
Rollsheet (const Rollsheet &r) {
numStudents= r.numStudents;
scores= new int [numStudents];
for (int i =0; i < numStudents; i++)
scores[i]= r.scores[i];
}
~Rollsheet () {
delete []scores;
}
void setScores (int s[]) {
for (int k=0; k<numStudents; k++)
scores[k] = s[k];
}
const int *getScores () {
return scores;
}
private:
int *scores;
int numStudents;
};
int main(){
Rollsheet listone;
listone.setScores;
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|