#include <iostream.h>
int add1CallByValue (int);
void add1ByPointer (int*);
void addByReference (int &);
main()
{
int count=5;
cout<<“Value returned by add1CallByValue:”<<add1CallByValue(count);
cout<<“Value returned by add1Bypointer:”<<add1ByPointer(&count);
cout<<“Value returned by add1ByReference:”<<add1ByPointer(count);
return 0;
}
int add1CallByValue (int a)
{
return a=a+1;
}
void add1ByPointer (int * countPtr)
{
*countPtr=*countPtr+1;
}
void add1ByReference (int & counter)
{
counter=counter+1;
}
错误如下:ompiling…
z1.15.cpp
c:\z1.15.cpp(12) : error C2679: binary “”<<“” : no operator defined which takes a right-hand operand of type “”void”” (or there is no acceptable conversion)
c:\z1.15.cpp(13) : error C2664: “”add1ByPointer”” : cannot convert parameter 1 from “”int”” to “”int *””
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
z1.15.obj – 2 error(s), 0 warning(s)