lundi 1 avril 2019

How can we create a variable in C++ as Java's blank final variable?

In Java we can declare a blank final variable and initialize it later once,for example :-

public void foo(){
       final int x; // declare the variable
       ...
       x = 0; //initialization only once
    }

how can we achieve this behavior in C/C++ using const or any other reasonable way? (without using const casting)

Thank you.

Aucun commentaire:

Enregistrer un commentaire