BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Error message when base class destructor called directly.

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Vladimir Grigoriev
Guest





PostPosted: Fri May 11, 2007 10:29 pm    Post subject: Error message when base class destructor called directly. Reply with quote



Is it correct error mesage

E2093 'operator'~' not implemented in type 'Stack' for arguments of the same
type

when I try to call base class destructor directly
~Stack();

Vladimir Grigoriev
Back to top
Sergiy Kanilo
Guest





PostPosted: Fri May 11, 2007 10:47 pm    Post subject: Re: Error message when base class destructor called directly Reply with quote



"Vladimir Grigoriev" <vlad.moscow (AT) mail (DOT) ru> wrote in message
news:4644a766 (AT) newsgroups (DOT) borland.com...
Quote:
Is it correct error mesage

E2093 'operator'~' not implemented in type 'Stack' for arguments of the
same type

yes, you are creating temporary Stack using default constructor
and apply operator~ to it

Quote:
when I try to call base class destructor directly
~Stack();

for direct destructor call you have to use -> or .
for example, in nonstatic member function

this->~Stack();

Cheers,
Serge

PS: and the next couple days we'll be discussing "why you should not do
that" Smile
Back to top
Vladimir Grigoriev
Guest





PostPosted: Fri May 11, 2007 10:53 pm    Post subject: Re: Error message when base class destructor called directly Reply with quote



O'k, I use

Stack::~Stack()
:)

Vladimir Grigoriev

"Sergiy Kanilo" <skanilo (AT) artannlabs (DOT) com> wrote in message
news:4644ac30$1 (AT) newsgroups (DOT) borland.com...
Quote:

yes, you are creating temporary Stack using default constructor
and apply operator~ to it

when I try to call base class destructor directly
~Stack();

for direct destructor call you have to use -> or .
for example, in nonstatic member function

this->~Stack();

Cheers,
Serge

PS: and the next couple days we'll be discussing "why you should not do
that" :)

Back to top
Sergiy Kanilo
Guest





PostPosted: Fri May 11, 2007 11:22 pm    Post subject: Re: Error message when base class destructor called directly Reply with quote

"Vladimir Grigoriev" <vlad.moscow (AT) mail (DOT) ru> wrote in message
news:4644accd (AT) newsgroups (DOT) borland.com...
Quote:
O'k, I use

Stack::~Stack()
:)

Vladimir Grigoriev

It not the standard way to call destructor (5.2.4).

I tried to compile

struct A
{
void f()
{
A::~A();
}
};

with three compilers and only one allows that

1) comeau online:
"ComeauTest.c", line 5: error: class "A" has no member "~A"

2) BDS2006 gives very strange error message
[C++ Error] Unit1.cpp(5): E2451 Undefined symbol '}'

3) MS VS2005 - seems ok with the code

All three compilers have no problem with this->~A();

Cheers,
Serge
Back to top
Dennis Cote
Guest





PostPosted: Fri May 11, 2007 11:46 pm    Post subject: Re: Error message when base class destructor called directly Reply with quote

Sergiy Kanilo wrote:
Quote:

PS: and <in> the next couple days we'll be discussing "why you should not do
that" :)


Sergiy,

I suspect that is true.

Dennis Cote
Back to top
Dennis Cote
Guest





PostPosted: Fri May 11, 2007 11:47 pm    Post subject: Re: Error message when base class destructor called directly Reply with quote

Vladimir Grigoriev wrote:
Quote:

when I try to call base class destructor directly


Vladimir,

Why are you trying to call a base class destructor?

Normally the compiler will do that for you if it's necessary.

Dennis Cote
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat May 12, 2007 12:56 am    Post subject: Re: Error message when base class destructor called directly Reply with quote

"Vladimir Grigoriev" <vlad.moscow (AT) mail (DOT) ru> wrote in message
news:4644a766 (AT) newsgroups (DOT) borland.com...

Quote:
I try to call base class destructor directly

Unless you used the 'placement new' operator to construct the class in
a block of preallocated memory, then you should NOT be calling any
destructor directly at all.


Gambit
Back to top
Vladimir Grigoriev
Guest





PostPosted: Mon May 14, 2007 4:47 pm    Post subject: Re: Error message when base class destructor called directly Reply with quote

"Sergiy Kanilo" <skanilo (AT) artannlabs (DOT) com> wrote in message
news:4644b454 (AT) newsgroups (DOT) borland.com...
Quote:

"Vladimir Grigoriev" <vlad.moscow (AT) mail (DOT) ru> wrote in message
news:4644accd (AT) newsgroups (DOT) borland.com...
It not the standard way to call destructor (5.2.4).

I tried to compile

struct A
{
void f()
{
A::~A();
}
};

2) BDS2006 gives very strange error message
[C++ Error] Unit1.cpp(5): E2451 Undefined symbol '}'

Cheers,
Serge


It is interesting if you will include in the structure
~A(){}
BCB 5.0 will not report any error.
Another bug of BCB? :)

Vladimir Grigoriev
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.