It is currently Tue Sep 07, 2010 7:07 am


All times are UTC [ DST ]


Ask on Codemiles community and get answers Free and Fast :

Ask your C-C++ questions ,C-C++ codes,C-C++ tricks ,C-C++ faq ,C-C++ answers .and more

Our guest share with us your code snippets , your programming problems , your open source projects ,read articles and post yours .







Post new topic Reply to topic  [ 3 posts ] 
  Print view Previous topic | Next topic 
Author Message
 Post subject: Operator overloading easy code
PostPosted: Sun May 25, 2008 5:44 pm 
Offline
Beginner
User avatar

Joined: Sun May 25, 2008 5:34 pm
Posts: 95
Has thanked: 2 time
Have thanks: 0 time

This an easy code for operating overloading :yahoo:
Code:
//So now you ask, what is this operator overloading stuff, how will it help me make the supreme burrito, and what the heck does "binary operator overloading" mean? Lets take this one step at a time. First, a quick example of operator overloading.

#include <iostream.h>

class Burrito
{
  private:
    int amtbeef, amtbean;
  public:

    Burrito(int beef, int bean) {
      amtbeef = beef;
      amtbean = bean;
    }
    Burrito operator + (Burrito newburrito)
   {
      int newbeef = amtbeef + newburrito.amtbeef;
      int newbean = amtbean + newburrito.amtbean;
      return Burrito(newbeef, newbean);
    }
};

void main(void)
{
  Burrito b1(5,10), b2(10,5), b3;
  b3 = b1 + b2;

//  cout<<b3<<endl;
}





TOP
 Profile Send private message  
 
| More
 Post subject: Re: Operator overloading easy code
PostPosted: Sun May 25, 2008 5:56 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 1588
Location: Earth
Has thanked: 10 time
Have thanks: 17 time

Thanks :gOOd:

_________________
Currenlty programming with : java , html , php , and javascript .


TOP
 Profile Send private message  
 
| More
 Post subject: Re: Operator overloading easy code
PostPosted: Sun May 25, 2008 6:28 pm 
Offline
Expert
User avatar

Joined: Tue Nov 06, 2007 2:17 pm
Posts: 847
Has thanked: 0 time
Have thanks: 0 time

operator overloading help programmer so much in data structure

like stack in this example

Stack outer_stack;
for (int i = 0; i < 1000000; i‚‚) {
Stack inner_stack;
inner_stack.push(some_data);
inner_stack = outer_stack;
}

can you figure out where will be the problem without using operator overloading? :club:

_________________
Any help needed just reply to my topic ,
ccna ,ccnp certified .


TOP
 Profile Send private message  
 
| More
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


 Similar topics
 Topic title   Forum   Author   Replies 
 java code for decision tree algorithm  Java  PERRYS  2
 3d OpenGL game with source code  Finished Projects  danayld  0
 3D c++ game with source code  C-C++  danayld  2
 Ajax Source code to Suggest application with JSP Server side  AJAX  msi_333  3
 NotePad C# code  C#  karim  2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  





Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2009
mileX v1.0 designed by codemiles team