> If your “C++” experience is the same as your English > experience then I don’t have to argue with you. You will > understand it later (in 1~2 years). :-) :-) :-) :-) you kick donkey's balls
Look, sucker, what about my English somehow you are right. More over, I speak in 3 languages and my grammar was alwait bad. You are stupid twice if you notices it just now ;-))))
What about C++, even you are laughing.
> > let's do another exersise : > > > > > > > #include <iostream>
> > > using namespace std;
> > >
> > > class Base {
> > > public:
> > > virtual int f() const { return 1; }
> > > };
> > >
> > > class Derived : public Base {
> > > public:
> > > int f() const { return 2; }
> > void foo()
> > {
> > this->~Derived();
> > new (this)Base;
> > f(); // is here late or early binding ???
> > // according your words, here must by early
> > binding. right? look at the results
> Read my first post again and read this:
> foo()
> {
> f();
> //is equal to
> this->f();//address is used, which
> //means the information is incomplete. Now you see it.
> Late binding.
> //if you don’t believe me look at this assembler code
> generated by VC compiler.
>
> 62: this->f();
> 00401589 mov eax,dword ptr [ebp-4]
> 0040158C mov edx,dword ptr [eax]
> 0040158E mov esi,esp
> 00401590 mov ecx,dword ptr [ebp-4]
> 00401593 call dword ptr [edx+4]
> 00401596 cmp esi,esp
> 00401598 call __chkesp (00401c50)
> 63: f();
> 0040159D mov eax,dword ptr [ebp-4]
> 004015A0 mov edx,dword ptr [eax]
> 004015A2 mov esi,esp
> 004015A4 mov ecx,dword ptr [ebp-4]
> 004015A7 call dword ptr [edx+4]
> 004015AA cmp esi,esp
> 004015AC call __chkesp (00401c50)
right !!! I meant exactly this. in this case it is always called via vtbl. here are your words :
The compiler knows the exact type and that it’s an object, so it can’t possibly be an object derived from Base — it’s exactly a Base. Thus early binding is probably used.
class A
{
void foo()
{
; // Do I know who am I ???
}
};
---
> > } > > } > > > }; > > > > > > int main() { > > > Derived d; > > > Base* b1 = &d; > > > Base& b2 = d; > > > Base b3; > > > // Late binding for both: > > > cout << "b1->f() = " << > b1->f() > > > << endl; > > > cout << "b2.f() = " << b2.f() > << > > endl; > > > // Early binding (probably): > > ^^^^^^^^^^^^^ good words. you can only suppose, but I > gues > > you are not sure. > Yes, I am not sure. But many compilers were constructed to > do “early binding” there. > > > cout << "b3.f() = " << b3.f() > << > > endl; > > > } ///:~ > > --- > > > > > In b1–>f( ) and b2.f( ) addresses are used, > which > > means > > > the information is incomplete: b1 and b2 can > represent > > the > > > address of a Base or something derived from Base, > so > > the > > > virtual mechanism must be used. When calling > b3.f( ) > > > there’s no ambiguity. The compiler knows the > exact > > type and > > > that it’s an object, so it can’t possibly be an > object > > > derived from Base — it’s exactly a Base. Thus > early > > binding > > > is probably used. However, if the compiler > doesn’t > > want to > > > work so hard, it can still use late binding and > the > > same > > > behavior will occur. > > Very logic, but not completed. as i said we can only > > suppose. looking at the results you are right, but the > > question was is it correct ? > It is not correct. It is just an optimization, because > nobody tries to “TPAX” an object such way as you do. look, it is ever possible to avoid bug. We do not discuss about sexual orientations. The code which I wrote is correct.
in VC++ try this
#inclide <windows.h>
class Ellipse
{
public:
void foo()
{}
};
int main()
{
Ellipse* p = new Ellipse;
p->foo();
return 0;
}
---
is anything incorrect? But try to compile this. Is it bug?
but of course we can avoid this, just declare Ellipse as XEllipse. So, should we pay attention on it or keep silence?
> > > > > > > > P.S. tema zakryta. > > З.Ы. давно пора. > Chto takoe "З.Ы." ? :-} З.Ы. => very terrible words
Армянскому радио спрашивают - можно ли трахаться на Красной площади.
ответ - можно, но не советуем. Будут слишком много советчиков.
мораль - то что происходит в коде даже моя бабушка со зрением -10 увидеть сможет. вопрос стоит является это багом или так и должно быть. совет - не ленись, почитай все мессаги. понимаю что связь плохая. попроси у XR-a может он разрешит попользоваться его прокси.
могу себе позволить подумать, что у тебя хреновый опыт работы с узерами. т.к. узер очень хитрыми комбинациями действий крашнет твою прогу. да еще так, что ты никогда не догодаешься как такое возможно. так что же из этого? показать узеру красную карточку и удалить из поля словами - нехер было изнываться над программой.
regards
|