Re: Virtual functions and destructors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Benjamin Sobotta wrote:

> > > I'm not sure if this is right. Functions can always be overloaded.
> >
> > He did not speak of functions being overloaded. He spoke of functions being
> > over-*ridden*.
> 
> Sorry I must have read wrong. Nevertheless even if you prefer to say override 
> you can still override a function without using virtual. Just adjust the type 
> of the pointer to the class of which you want to execute the member function.

That isn't really "overriding" anything, just calling a different
function.

Two functions (members or not) which have the same name but different
argument types are completely separate functions. The fact that they
have the same name is (almost[1]) entirely cosmetic; you could just as
easily give them separate names. E.g. if you have:

	void foo(int);
	void foo(float);

you could equally just use:

	void foo_i(int);
	void foo_f(float);

Overloading just lets you omit the type annotation from the name.

[1] The only situation where the ability to overload function names
really makes a difference is when using templates.

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux