Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Argumen referensi 'argumen' untuk fungsi 'function' dapat ditandai sebagai
const(con.3).
Keterangan
Meneruskan objek berdasarkan referensi menunjukkan bahwa fungsi memiliki potensi memodifikasi objek. Jika itu bukan niat fungsi, lebih baik menandai argumen sebagai referensi const.
Nama analisis kode: USE_CONST_REFERENCE_ARGUMENTS
Contoh
struct MyStruct
{
void MemberFn1() const;
void MemberFn2();
};
void Function1_Helper(const MyStruct&);
void Function1(MyStruct& myStruct) // C26460, see comments below.
{
myStruct.MemberFn1(); // The member function is marked as const
Function1_Helper(myStruct); // Function1_Helper takes a const reference
}
void Function2(MyStruct& myStruct)
{
myStruct.MemberFn2(); // MemberFn2 is non-const and has the potential to modify data
}