- Eine „intg“-Funktion kann keine Nicht-„intg“-Funktionen aufrufen. (Dasselbe gilt, wenn wir nicht-konstante Funktionen nicht in konstanten Funktionen aufrufen können)
- „intg“-Variablen können nur in „intg“-Funktionen geändert werden („intg“-Variablen fungieren als Konstante, wenn sie sich in anderen Funktionen befinden)
Wie würde ich vorgehen? Tun Sie dies in C++ oder fügen Sie es einem Compiler hinzu?
Beispiel:
Code: Select all
intg float a = 0;
float b = 0;
void DoStuff() intg
{
// Doing stuff...
}
void Foo() intg
{
DoStuff() // Allowed!
DoThings() // Allowed!
a = 2; // Allowed!
b = 2; // Allowed!
// And other stuff...
}
void DoThings()
{
// Doing thing...
}
void Bar()
{
DoStuff() // Compilation error!
DoThings() // Allowed!
a = 2; // Compilation error!
b = 2; // Allowed!
}