Our social:
Propellerads

Latest Post

Saturday, 28 May 2016

OOPS Concept

OOPS CONCEPT


  1. Class – group of data members & member functions
  2. Like person can be class having data members heightand weight and member functions as get_details() and put_details() to manipulate on details
  3. Class is nothing until you create it’s object
  4. Object – instantiates class allocates memory

OOPS Fundamentals…

Access to data members & member functions can be
done using object only (if they are not static!)

OOPS features are: 

1. Encapsulation

2. Data hiding
3. Data reusability
4. Overloading (polymorphism)
5. Overriding

OOPS Features…

  1. Encapsulation – making one group of data members & member functions
  2. Can be done through class
  3. Then group of data members & Member functions will
  4. be available just by creating object.
  5. Data Hiding – can be done through access modifiers
  6. Access modifiers are private, public, protected and internal
  7. Private members or member function won’t be available outside class
  8. Public – available all over in program outside class also
  9. rotected – members that are available in class as well as in it’s child class
  10. Private for another class
  11. Protected access modifier comes only when inheritance is in picture
  12. Internal is used with assembly creation


EXAMPLE :


class employee //Class Declaration
{
private:
char empname[50];
int empno;
public:
void getvalue() {
cout<<"INPUT Employee Name:";
cin>>empname;
cout<<"INPUT Employee Number:";
cin>>empno; }
void displayvalue() {
cout<<"Employee Name:"<<empname<<endl;
cout<<"Employee Number:"<<empno<<endl; }
};
main()
{
employee e1; //Creation of Object
e1.getvalue();
e1.displayvalue();
}

Pages (12)1234567 Next »