Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class Student{
- private:
- int *marks;
- int numOfCourse;
- public:
- Student():Student(1){}
- Student(int numOfCourse){
- this->numOfCourse = numOfCourse;
- this->marks = new int[this->numOfCourse];
- this->takeMarks();
- }
- void takeMarks(){
- cout<<"Enter "<<this->numOfCourse << " marks for this student\n";
- for(int i=0; i<this->numOfCourse; i++)
- cin>>this->marks[i];
- }
- void showMarks(){
- for(int i=0; i<this->numOfCourse; i++)
- cout<<this->marks[i]<<" ";
- cout<<endl;
- }
- ~Student(){
- delete [] this->marks;
- }
- };
- int main(){
- Student *s1 = new Student;
- Student s2;
- s2 = *s1;
- delete s1;
- s2.showMarks();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement