oop lec 5-(class objects, constructor & destructor)

26
CLASS OBJECTS, CONSTRUCTOR & DESTRUCTOR Object Oriented Programming COMSATS Institute of Information Technology

Upload: asfand-hassan

Post on 21-Aug-2015

712 views

Category:

Education


1 download

TRANSCRIPT

  1. 1. CLASS OBJECTS, CONSTRUCTOR & DESTRUCTOR Object Oriented Programming COMSATS Institute of Information Technology
  2. 2. Book ClassObject Oriented Programming#include #include Data Hiding class book{ Data is concealed within the class private: char name[25]; Cannot be access by function int pages; outside the class float price; Primary mechanism to hide data public: is to make it private void changeName(char *n){ Private data and function can strcpy(name, n); Class only be access from within the } Definition class void changePages(int p){ pages = p; } void changePrice(float p){ price = p; } void display(){ cout