Connecting Tech Pros Worldwide Help | Site Map

"interface"

  #1  
Old July 22nd, 2005, 11:20 AM
seesaw
Guest
 
Posts: n/a
When define an interface of all pure virtual functions, will the destructor
of it will automatically virtual, or it has to be declared as virtual?
Should it be declared as "virtual" when defining the interface?


  #2  
Old July 22nd, 2005, 11:20 AM
Phlip
Guest
 
Posts: n/a

re: "interface"


seesaw wrote:
[color=blue]
> When define an interface of all pure virtual functions, will the[/color]
destructor[color=blue]
> of it will automatically virtual, or it has to be declared as virtual?
> Should it be declared as "virtual" when defining the interface?[/color]

In C++, you don't pay for what you don't use.

Suppose, someday many winters from now, you wrote a program, and then
profiled it, and discovered the only way to make it faster was to take out a
single virtual destructor.

If the C++ committees had decreed that undeclared destructors of purely
abstract base classes were magically virtual, you would be screwed.

So, until that day, get in the habit of writing...

virtual ~myClass() = 0;

....to make destructors pure virtual, too.

(If the abstract class weren't pure - if it had a member that needs
destruction, the = 0 won't prevent this.)

--
Phlip
http://www.xpsd.org/cgi-bin/wiki?Tes...UserInterfaces




  #3  
Old July 22nd, 2005, 11:20 AM
John Carson
Guest
 
Posts: n/a

re: "interface"


"seesaw" <seesaw@turboweb.com> wrote in message
news:oI%jc.33906$_o3.1100044@bgtnsc05-news.ops.worldnet.att.net[color=blue]
> When define an interface of all pure virtual functions, will the
> destructor of it will automatically virtual, or it has to be declared
> as virtual? Should it be declared as "virtual" when defining the
> interface?[/color]

It has to be declared virtual.


--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
"No matching function on interface" when Method contains COMenumeration Peter answers 0 September 5th, 2008 04:25 AM
Error with "internal interface" ~~~ .NET Ed ~~~ answers 4 June 15th, 2007 10:25 PM
Adding an "Interface" from IDL / tlb files to an existing win32COM-Object VolkerS answers 2 February 26th, 2007 07:39 AM
"Interface" for a form object Antony answers 11 November 20th, 2005 03:02 AM
"cannot serialize interface" error in web service, help please n_o_s_p_a__m answers 1 November 15th, 2005 12:44 PM