Oharra
Baimena behar duzu orria atzitzeko. Direktorioetan saioa has dezakezu edo haiek alda ditzakezu.
Baimena behar duzu orria atzitzeko. Direktorioak alda ditzakezu.
El argumento de puntero 'argument' para la función 'function' se puede marcar como puntero a
const(con.3).
Comentarios
Una función con un argumento T* tiene la posibilidad de modificar el valor del objeto. Si no es la intención de la función, es mejor que el puntero sea en const T* su lugar.
Nombre de análisis de código: USE_CONST_POINTER_ARGUMENTS
Ejemplo
struct MyStruct
{
void MemberFn1() const;
void MemberFn2();
};
void Function1_Helper(const MyStruct* myStruct);
void Function1(MyStruct* myStruct) // C26461, neither of the operations on myStruct would modify the pointer's value.
{
if (!myStruct)
return;
myStruct->MemberFn1(); // The member function is const
Function1_Helper(myStruct); // Function1_Helper takes a const
}
void Function2(MyStruct* myStruct)
{
if (!myStruct)
return;
myStruct->MemberFn2(); // The member function is non-const, so no C26461 will be issued
}