Hi
This type of function overloading works in c .
Execute following code and it will call function fun as per the
function parameter
code snip-in
---------------------
#include<stdio.h>
void fun(const char *p)
{
printf("funsfsdafsf1\n");
}
void fun(char *P)
{
printf("fun2\n");
}
void main()
{
char str[] = "funcheck";
const char str1[] = "constcheck";
fun(str);
fun(str1);
}
---------------------
output
------------
fun2
funsfsdafsf1
----------------
Mayur
On Nov 21, 6:30 pm, Anil Arya <[email protected]> wrote:
> dude....compile using g++
>
> On 11/21/11, atul anand <[email protected]> wrote:
>
>
>
>
>
>
>
>
>
> > this is what i am getting after executing code meintion in the above link.
>
> > (using gcc compiler )
>
> > temp.c:12: error: conflicting types for 'fun'
> > temp.c:7: error: previous definition of 'fun' was here
>
> > On Mon, Nov 21, 2011 at 3:09 PM, UTKARSH SRIVASTAV
> > <[email protected]>wrote:
>
> >>http://www.ideone.com/JQFNh
> >> CHECK THE OUTPUT THERE IS NO AMBIGUITY BUT PLEASE EXPLAIN THE RESULTS
>
> >> On Sun, Nov 20, 2011 at 11:00 PM, Akash Coder
> >> <[email protected]>wrote:
>
> >>> it wont work
>
> >>> even this wont
>
> >>> function(char a[])
> >>> function (char *)
> >>> coz the two forms are interchangeable
>
> >>> On Sun, Nov 20, 2011 at 10:12 PM, saurabh singh
> >>> <[email protected]>wrote:
>
> >>>> wont work......Thre is no way compilers gonna guess which function to
> >>>> call.The const qualifier only guarantees that the value at the address
> >>>> wont
> >>>> be altered inside the function.That has nothing to do with calling,
>
> >>>> On Sun, Nov 20, 2011 at 9:50 PM, rahul vatsa
> >>>> <[email protected]>wrote:
>
> >>>>> yes, it will work.
>
> >>>>> On Sun, Nov 20, 2011 at 9:12 PM, Akash Coder <
> >>>>> [email protected]> wrote:
>
> >>>>>> no it wont work ... const is not a datatype. its a qualifier
>
> >>>>>> On Sun, Nov 20, 2011 at 7:49 PM, rahul sharma <[email protected]
> >>>>>> > wrote:
>
> >>>>>>> void fun(char *)
> >>>>>>> void fun(const char *)
>
> >>>>>>> is this overloading works or these are same type of arguments??????
>
> >>>>>>> --
> >>>>>>> You received this message because you are subscribed to the Google
> >>>>>>> Groups "Algorithm Geeks" group.
> >>>>>>> To post to this group, send email to [email protected].
> >>>>>>> To unsubscribe from this group, send email to
> >>>>>>> [email protected].
> >>>>>>> For more options, visit this group at
> >>>>>>>http://groups.google.com/group/algogeeks?hl=en.
>
> >>>>>> --
> >>>>>> You received this message because you are subscribed to the Google
> >>>>>> Groups "Algorithm Geeks" group.
> >>>>>> To post to this group, send email to [email protected].
> >>>>>> To unsubscribe from this group, send email to
> >>>>>> [email protected].
> >>>>>> For more options, visit this group at
> >>>>>>http://groups.google.com/group/algogeeks?hl=en.
>
> >>>>> --
> >>>>> You received this message because you are subscribed to the Google
> >>>>> Groups "Algorithm Geeks" group.
> >>>>> To post to this group, send email to [email protected].
> >>>>> To unsubscribe from this group, send email to
> >>>>> [email protected].
> >>>>> For more options, visit this group at
> >>>>>http://groups.google.com/group/algogeeks?hl=en.
>
> >>>> --
> >>>> Saurabh Singh
> >>>> B.Tech (Computer Science)
> >>>> MNNIT ALLAHABAD
>
> >>>> --
> >>>> You received this message because you are subscribed to the Google
> >>>> Groups "Algorithm Geeks" group.
> >>>> To post to this group, send email to [email protected].
> >>>> To unsubscribe from this group, send email to
> >>>> [email protected].
> >>>> For more options, visit this group at
> >>>>http://groups.google.com/group/algogeeks?hl=en.
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups
> >>> "Algorithm Geeks" group.
> >>> To post to this group, send email to [email protected].
> >>> To unsubscribe from this group, send email to
> >>> [email protected].
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/algogeeks?hl=en.
>
> >> --
> >> *UTKARSH SRIVASTAV
> >> CSE-3
> >> B-Tech 3rd Year
> >> @MNNIT ALLAHABAD*
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected].
> >> For more options, visit this group at
> >>http://groups.google.com/group/algogeeks?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.
>
> --
> *Anil Arya,
> Computer Science *
> *Motilal Nehru National Institute of Technology,Allahabad .
> *
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.