HOME BZU Mail Box Online Games Radio and TV Live Cricket Score All Albums
Go Back   BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan Institute of Computing Bachelor of Science in Information Technology BsIT 3rd Semester Object Oriented Programming

Object Oriented Programming By Mam Sidra Malik


Reply
 
Thread Tools Search this Thread Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 24-10-2008, 04:04 PM
shmsa's Avatar
Grown up punk

 

Join Date: Oct 2007
Location: Muslim Town Multan
Posts: 195
Contact Number: 0322-6196713
Program / Discipline: BSIT
Class Roll Number: 07-22
shmsa is a jewel in the roughshmsa is a jewel in the roughshmsa is a jewel in the roughshmsa is a jewel in the rough
Read Use of Binary Operator on class objects using C++


#include <iostream> using namespace std; class dist { private: int feet; int inches; public: dist() { feet=2; inches=6; } dist(int f,int inc) { feet=f; inches=inc; } dist operator +(dist d2) { dist temp; temp.feet=feet + d2.feet; temp.inches=inches+d2.inches; if(temp.inches >= 12) { temp.feet++; temp.inches-=12; } return temp; } ///////////////////////////////// dist operator *(dist d2) { dist temp; temp.feet=feet * d2.feet; temp.inches=inches * d2.inches; if(temp.inches >= 12) { temp.feet+=temp.inches/12; temp.inches-=(temp.inches/12)*12; } return temp; } //////////////////////////////////////////////// copied from bzupages.com dist operator -(dist d2) { dist temp; if(inches < d2.inches) { feet--; inches+=12; } temp.feet=feet - d2.feet; temp.inches = inches - d2.inches; return temp; } bool operator >(dist d2) { bool yes,no; //yes=true; // no=false; if(feet>d2.feet) return true; else return false; } bool operator <(dist d2) { bool yes,no; //yes=true; // no=false; if(feet < d2.feet) return true; else return false; } void show() { cout<<"the value of feet"<<feet<<endl; cout<<"the value of inches"<<inches<<endl; } }; void main() { dist d1;//2 6 dist d2(1,4); dist d3(25,9); d3=d1+d2; if(d1>d2) d3=d1-d2; else d3=d2-d1; d3=d1*d2; d3.show(); }
Reply With Quote
Reply

Tags
binary, class, objects, operator


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Light Convert 2-D Patterns Into 3-D Objects Kamzkami Tech world 0 11-11-2011 08:09 PM
Proposal of a 3th class boy to 9th class girl. usman_latif_ch Funny Cut Piece 0 02-11-2011 07:13 PM
HP TopShot LaserJet Pro multifunction lets you scan 3D objects .BZU. Tech world 0 11-09-2011 07:22 AM
The C++ Modulus Operator bonfire Introduction to Computing 0 26-02-2011 11:15 PM
How to use Uniry Operator on class objects using C++ shmsa Object Oriented Programming 0 24-10-2008 03:59 PM

Best view in Firefox
Almuslimeen.info | Cloud Computing | Dedicated server hosting
Note: All trademarks and copyrights held by respective owners. We will take action against any copyright violation if it is proved to us.

All times are GMT +5. The time now is 02:11 AM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.