Home > Software engineering >  Drop pit.. The original code in vs2019 compiler through
Drop pit.. The original code in vs2019 compiler through

Time:10-12

 
Class A
{
Public:
A () {}
Virtual ~ (A) {TRACE (" 3 \ r \ n "); }


Virtual BOOL Create (DWORD a) {
TRACE (" 2 \ r \ n ");
return TRUE; }
};


Class B: public A
{
Public:
(B) {}
Virtual ~ (B) {TRACE (" 4 \ r \ n "); }


BOOL Create (DWORD a, dwords b, int) c {
TRACE (" 1 \ r \ n ");
return true;
}
};


A * p=new B;//this place will not automatically convert type (p) (B *) - & gt; Create (1, 2, 3);
P - & gt; Create (1, 2, 3);




Is already in use code.. Drop pit under the VS2019 16.7.3
Is there anything new transformation method

CodePudding user response:

The parameters of the virtual function form and shall be the same number, to pass a base class pointer call
Parameters written form, or clear type again call

 
Class A
{
Virtual BOOL Create (DWORD a, dwords b=0, int c=0).
}
Class B: public A
{
Virtual BOOL Create (DWORD a, dwords b=0, int c=0).
}
P - & gt; Create (1, 2, 3);

Or
((B *) p) - & gt; Create (1, 2, 3)




CodePudding user response:

Class B: public A
{
virtual BOOL Create (DWORD a, dwords b=0, int c=0).
}

CodePudding user response:

reference 1st floor zgl7903 response:
the parameters of the virtual function form and shall be the same number, can call through a base class pointer
Parameters written form, or clear type again call

 
Class A
{
Virtual BOOL Create (DWORD a, dwords b=0, int c=0).
}
Class B: public A
{
Virtual BOOL Create (DWORD a, dwords b=0, int c=0).
}
P - & gt; Create (1, 2, 3);

Or
((B *) p) - & gt; Create (1, 2, 3)





For he must now a new version of this but don't have to before 2019 16.7.3 vs2015 vs2013 can be called directly derived classes of the Create

My original code has been used in the production of

Egg painful thing cannot compile 2019 also now is not the old version

CodePudding user response:

refer to the second floor schlafenhamster response:
class B: public A
{
virtual BOOL Create (DWORD a, dwords b=0, int c=0).
}


This way I know

There are forced to specify the type (p) (B *) - & gt; Create (1, 2, 3)

So I framework is useless

I have a lot of parameters of derived classes are not the same

Only in this vs2019 new version compiled on the old version can be vs2015 2013 normal can

If the change of quantities is too big

Vs2019 old version can't install this thing really grass eggs
  • Related