Download presentation
Presentation is loading. Please wait.
Published byJudith Higgins Modified over 9 years ago
2
http://cs.mst.edu Object-Oriented Paradigm
3
http://cs.mst.edu 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
4
http://cs.mst.edu Your First Class class name_of_type { public: // function prototypes here private: // member data here };
5
http://cs.mst.edu Your First Class class name_of_type { public: // function prototypes here private: // member data here }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; };
6
http://cs.mst.edu Your First Class class name_of_type { public: // function prototypes here private: // member data here }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; };
7
http://cs.mst.edu Your First Class class name_of_type { public: // function prototypes here private: // member data here }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; };
8
http://cs.mst.edu Your First Class class name_of_type { public: // function prototypes here private: // member data here }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; };
9
http://cs.mst.edu Your First Class class name_of_type { public: // function prototypes here private: // member data here }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; };
10
http://cs.mst.edu Your First Class class name_of_type { public: // function prototypes here private: // member data here }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; };
11
http://cs.mst.edu Private By Default class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; }; class Fraction { int m_Numerator; int m_Denominator; public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); };
12
http://cs.mst.edu Private By Default class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; }; class Fraction { int m_Numerator; int m_Denominator; public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); };
13
http://cs.mst.edu 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: int m_Numerator; int m_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }
14
http://cs.mst.edu 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: int m_Numerator; int m_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }
15
http://cs.mst.edu 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: int m_Numerator; int m_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!
16
http://cs.mst.edu 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: int m_Numerator; int m_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }
17
http://cs.mst.edu 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: int m_Numerator; int m_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }
18
http://cs.mst.edu 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: int m_Numerator; int m_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }
19
http://cs.mst.edu End of Session
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.