Friday, 20 January 2012

Student Class in C++ OOPs Example

#include<iostream>
#include<conio.h>
using namespace std;
class Student{
      private:
              int marks;
      public:
             void setMarks(int a){
                  marks=a;
                  }
             void getMarks(){
                  cout<<"marks of student is "<<marks<<endl;
                  }
      };
      int main(){
          Student s1;
          s1.setMarks(84);
          s1.getMarks();
          s1.setMarks(90);
          s1.getMarks();
          getch();
          return 0;
          }
         

No comments:

Post a Comment