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). }