| View previous topic :: View next topic |
| Author |
Message |
Vladimir Grigoriev Guest
|
Posted: Fri May 11, 2007 10:29 pm Post subject: Error message when base class destructor called directly. |
|
|
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
|
Posted: Fri May 11, 2007 10:47 pm Post subject: Re: Error message when base class destructor called directly |
|
|
"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"  |
|
| Back to top |
|
 |
Vladimir Grigoriev Guest
|
Posted: Fri May 11, 2007 10:53 pm Post subject: Re: Error message when base class destructor called directly |
|
|
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
|
Posted: Fri May 11, 2007 11:22 pm Post subject: Re: Error message when base class destructor called directly |
|
|
"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
|
Posted: Fri May 11, 2007 11:46 pm Post subject: Re: Error message when base class destructor called directly |
|
|
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
|
Posted: Fri May 11, 2007 11:47 pm Post subject: Re: Error message when base class destructor called directly |
|
|
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
|
Posted: Sat May 12, 2007 12:56 am Post subject: Re: Error message when base class destructor called directly |
|
|
"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
|
Posted: Mon May 14, 2007 4:47 pm Post subject: Re: Error message when base class destructor called directly |
|
|
"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 |
|
 |
|