180 likes | 385 Views
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:
E N D
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: // function prototypes here private: // member data here };
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 };
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 };
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 };
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 };
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 };
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 };
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; };
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; };
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; }
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; }
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!
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; }
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; }
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; }