l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
December 2: Social gathering
Next Installfest:
TBD
Latest News:
Nov. 18: Club officer elections
Page last updated:
2010 Feb 11 12:26

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] overloading in C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] overloading in C



On Wed, Feb 10, 2010 at 10:58:48PM -0800, Bill Kendrick wrote:
> On Wed, Feb 10, 2010 at 10:10:31PM -0800, Brian Lavender wrote:
> > I guess in C, you can't overload a function?
> <snip>
> 
> You could use "...", like prinf() and scanf() use. ;)
> 

This seemed to do the trick.

> What I end up doing (and have seen other C-based APIs do) is
> something like this:
> 
>   void oldfunction(type1 arg1)
>   { ...some code... }
> 
> oops, I need two args!  Rewrite time!
> 
>   void newfunction(type1 arg1, type2 arg2)
>   { ...some code... }
> 
>   void oldfunction(type1 arg1)
>   {
>     newfunction(arg1, somedefault);
>   }
> 
> 
> So now, anything that used oldfunction() still works as-is
> (API didn't change), but if I need the additional arguments,
> I can call the newer function (which really started life as
> a rename of the old function, then had some code added to it).


-- 
Brian Lavender
http://www.brie.com/brian/

"Too much hype, too much confusion, and too many people talking about
something they don't understand have greatly muddied the waters in the
last year or so."

Borland Turbo Pascal OO Programming Guide
1989
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.