C and C ++ are mostly consistent and compatible in terms of basic syntax, but they still differ in Function Definition and calling. See the following code:
# Include "stdafx. H"
Int subtest (x, y)
Int * X, * Y;
...{
Int Z;
Z = * x> * y? * X: * Y;
Return (z );
}
Int main (INT argc, char * argv [])
...{
// Printf ("Hello world! ");
Int A = 10;
Int B = 20;
Printf ("% d", subtest (& A, & B ));
Return 0;
}
This method is called the traditional declaration method of the form parameter. The following is the declaration method of the modern form parameter allowed by the C ++ standard:
# Include "stdafx. H"
Int subtest (x, y)
Int * X, * Y;
...{
Int Z;
Z = * x> * y? * X: * Y;
Return (z );
}
Int main (INT argc, char * argv [])
...{
// Printf ("Hello world! ");
Int A = 10;
Int B = 20;
Printf ("% d", subtest (& A, & B ));
Return 0;
}
In vc6.0, *. c files can be used in the previous way. *. cpp files cannot be used in the previous way. The error is as follows:
F:/testfun. cpp (5): Error c2065: 'X': Undeclared identifier
F:/testfun. cpp (5): Error c2065: 'y': Undeclared identifier
F:/testfun. cpp (6): Error c2448: '<Unknown>': function-style initializer appears to be a Function Definition
F:/testfun. cpp (6): Fatal error c1004: unexpected end of file found
Error executing cl.exe.
Testfun.exe-4 error (s), 0 warning (s)
It can be seen that the C standard and the C ++ standard are not completely consistent, especially some C language proprietary functions such as malloc alloc and other processing methods are very different.