add casts

add inline
add template
This commit is contained in:
2025-09-23 18:17:48 +02:00
parent 3b35b973c9
commit bc4b9f1691
9 changed files with 142 additions and 3 deletions
+30
View File
@@ -26,6 +26,8 @@ int main()
pNumber = nullptr;
}
safeDelete(pNumber);
// pointer as references outside local scope
int number = 10;
changeInteger(number);
@@ -74,5 +76,33 @@ int main()
pNumber = nullptr;
}
// const example
const int constNumber = 10;
//constNumber = 20; // a const value can not be changed
const int* constNumberPointer = new int(10);
//*constNumberPointer = 20; // this is a const value
constNumberPointer = new int(20); // but not a const pointer
int const* numberConstPointer = new int(10);
//*numberConstPointer = 20; // this is a const value
numberConstPointer = new int(20); // but not a const pointer
int* const numberPointerConst = new int(10);
*numberPointerConst = 20; // the value is not const
//numberPointerConst = new int(20); // but the pointer is const
const int* const constNumberPointerConst = new int(10);
//*constNumberPointerConst = 20; // this is a const value
//constNumberPointerConst = new int(20); // and the pointer as well
int const* const numberConstPointerConst = new int(10);
//*numberConstPointerConst = 20; // this is a const value
//numberConstPointerConst = new int(20); // and the pointer as well
const int const* const constNumberConstPointerConst = new int(10);
//*constNumberConstPointerConst = 20; // this is a const value
//constNumberConstPointerConst = new int(20); // and the pointer as well
return 0;
}