Docsity

Cpp-Object Oriented Programming-Lecture Slides, Slides of Object Oriented Programming

Partial preview of the text

Download Cpp-Object Oriented Programming-Lecture Slides and more Slides Object Oriented Programming in PDF only on Docsity!

Object Oriented Programming

Refresher Course on High Performance Computing

Module-III

Dr. Mohammad Jaudet, DEE

Mr. Arshad Iqbal, DCIS

Pakistan Institute of Engineering and Applied Sciences

August, 2010

Outline of the Lecture 05 (^1) C++ 2 Examples (^3) Example 1 (^4) Example 2 (^5) Exercises (^6) References 7 Thanks

C++ Programming Language, ... One of the Most Popular Programming Languages ever Created C++ is widely used in the Software Industry. Systems Software, Application Software, Device Drivers, High Performance Server and client Applications, Embedded Software, Entertainment Software such as Video Games Several Groups Provide both Free and Proprietary C++ compiler software, including the GNU Project, Microsoft, Intel and Borland C++ has Greatly Influenced many other Popular Programming Languages, most notably Java

Examples Adding two Numbers Finding the Maximum of Two Numbers

Adding two Numbers class TwoNums { int x, y; };

Adding two Numbers class TwoNums { int x, y; public: void set_values (int, int); };

Adding two Numbers class TwoNums { int x, y; public: void set_values (int, int); int Sum () {return (x + y);} };

Adding two Numbers class TwoNums { int x, y; public: void set_values (int, int); int Sum () {return (x + y);} int Diff1 () {return (x - y);} };

Adding two Numbers class TwoNums { int x, y; public: void set_values (int, int); int Sum () {return (x + y);} int Diff1 () {return (x - y);} int Diff2 () {return (y - x);} ... ... };

Adding two Numbers class TwoNums { int x, y; public: void set_values (int, int); int Sum () {return (x + y);} int Diff1 () {return (x - y);} int Diff2 () {return (y - x);} ... ... }; void TwoNums::set_values (int a, int b) { x = a; y = b; }

Adding two Numbers, ... #include using namespace std; //Code from the Last Slide

Adding two Numbers, ... #include using namespace std; //Code from the Last Slide int main (void); int main (void) { };

Adding two Numbers, ... #include using namespace std; //Code from the Last Slide int main (void); int main (void) { TwoNums myTwoNums; //Declaration myTwoNums.set_values (3, 4); //Instantiation };

Adding two Numbers, ... #include using namespace std; //Code from the Last Slide int main (void); int main (void) { TwoNums myTwoNums; //Declaration myTwoNums.set_values (3, 4); //Instantiation cout << "Sum: " << myTwoNums.Sum (); };