Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- class Student {
- string nume;
- int nrNote;
- int *note;
- public:
- Student(string nume, int nrNote, int *note) {
- this->nume = nume;
- this->nrNote = nrNote;
- note = new int[nrNote];
- if (note)
- {
- for (int i = 1; i < nrNote; i++)
- this->note[i] = note[i];
- }
- else
- note = NULL;
- }
- Student(const Student& student) { // const sa nu modificam obiectul din greseala in copiere
- this->nume = student.nume;
- this->nrNote = student.nrNote;
- note = new int[nrNote];
- if (student.note)
- {
- for (int i = 1; i < nrNote; i++)
- this->note[i] = student.note[i];
- }
- else
- note = NULL;
- }
- ~Student(){
- if (note != NULL)
- delete[] note;
- }
- Student operator=(const Student& student) {
- this->nume = student.nume;
- this->nrNote = student.nrNote;
- note = new int[nrNote];
- if (student.note)
- {
- for (int i = 1; i < nrNote; i++)
- this->note[i] = student.note[i];
- }
- else
- note = NULL;
- }
- };
- int main() {
- int v[] = { 9,10,9,10 };
- Student student("Gigel", 4,v);
- Student s2(student);
- Student s3 = student;
- //s4=s2 s4.operator=(s2)
- // supraincarcare
- Student s4("Ana", 4, v);
- s4 = s2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement