GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 16-Sep-2008, 12:18
khushal_kkk's Avatar
khushal_kkk khushal_kkk is offline
Awaiting Email Confirmation
 
Join Date: Mar 2008
Posts: 50
khushal_kkk is an unknown quantity at this point

What is Function Overloading?


can any one help me

what is Function Overloading and try to explain by giving a practicle example
  #2  
Old 16-Sep-2008, 12:43
ocicat ocicat is offline
Regular Member
 
Join Date: May 2008
Posts: 580
ocicat is a jewel in the roughocicat is a jewel in the rough

Re: What is Function Overloading


Quote:
Originally Posted by khushal_kkk
what is Function Overloading and try to explain by giving a practicle example
Function overloading is the ability to use the same name in different functions which differ in argument lists. As an example,
CPP / C++ / C Code:
#include<iostream>

using namespace std;

float add(float, float);
float add(float, float, float);

int 
main() {
    cout << add(1.1, 2.2) << endl;
    cout << add(3.3, 4.4, 5.5) << endl;

    return 0;
}

float
add(float a, float b) {
    return a + b;
}

float
add(float a, float b, float c) {
    return a + b + c;
}
This is not possible in C. There, functions would have to be uniquely named.
  #3  
Old 19-Sep-2008, 21:01
Soybeanio Soybeanio is offline
New Member
 
Join Date: Jul 2008
Posts: 8
Soybeanio is on a distinguished road
Lightbulb

Re: What is Function Overloading?


Function overloading is just a way you can have different functions with the same name. To do that, you can give the functions different arguments.
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
run script command on ns2.26 newbie06 Computer Software Forum - Linux 65 19-Aug-2009 08:50
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 08:44
Flex and bison coding lucky88star C++ Forum 5 24-Dec-2007 12:57
Need Help with input files. Efferus C++ Forum 2 24-Nov-2007 17:19
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 14:12

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:46.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.