Page 10 - Microsoft Word - 53a6-4b9d-9f8f-9799
P. 10

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();

                     }
   5   6   7   8   9   10   11