1 / 18

Object-Oriented Paradigm

Object-Oriented Paradigm. The Concept. Bundled together in one object Data Types Functionality Encapsulation State variables used to describe the object Functions dictating how the object interacts and interfaces with other entities. Your First Class. class name_of_type { public:

prentice
Download Presentation

Object-Oriented Paradigm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object-Oriented Paradigm

  2. The Concept • Bundled together in one object • Data Types • Functionality • Encapsulation • State variables used to describe the object • Functions dictating how the object interacts and interfaces with other entities

  3. Your First Class class name_of_type { public: // function prototypes here private: // member data here };

  4. Your First Class class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; }; class name_of_type { public: // function prototypes here private: // member data here };

  5. Your First Class class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; }; class name_of_type { public: // function prototypes here private: // member data here };

  6. Your First Class class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; }; class name_of_type { public: // function prototypes here private: // member data here };

  7. Your First Class class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; }; class name_of_type { public: // function prototypes here private: // member data here };

  8. Your First Class class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; }; class name_of_type { public: // function prototypes here private: // member data here };

  9. Your First Class class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; }; class name_of_type { public: // function prototypes here private: // member data here };

  10. Private By Default class Fraction { • intm_Numerator; • intm_Denominator; public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; };

  11. Private By Default class Fraction { • intm_Numerator; • intm_Denominator; public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; };

  12. Definition and Use //fraction.h #ifndef FRACTION_H #define FRACTION_H class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }

  13. Definition and Use //fraction.h #ifndef FRACTION_H #define FRACTION_H class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }

  14. Definition and Use //fraction.h #ifndef FRACTION_H #define FRACTION_H class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; } //won’t compile!

  15. Definition and Use //fraction.h #ifndef FRACTION_H #define FRACTION_H class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }

  16. Definition and Use //fraction.h #ifndef FRACTION_H #define FRACTION_H class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }

  17. Definition and Use //fraction.h #ifndef FRACTION_H #define FRACTION_H class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: intm_Numerator; intm_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }

  18. End of Session

More Related