Page 11 - BUKU DIGITAL DODI
P. 11

10. Operator Scope Resulution (: : )

                    #include <iostream>
                    #include <conio.h>

                    using namespace std;

                    int total;


                    main(){

                       int total = 5;
                       cout << "total lokal = " << total << endl;

                       ::total = 7;    //contoh penggunaan

                       cout << "total global = " << ::total;

                       getch();
                    }

                   11. Variabel Static


                     #include <iostream>
                         #include <conio.h>
                     using namespace std;

                         lain(){
                            static int total = 0;

                       total++;
                           cout << "Nilai total = " << total << endl;
                     }

                         main(){
                     lain();

                     lain();

                     lain();
                     getch();

                     }
   6   7   8   9   10   11   12