Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

Lecture 6.pptx

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Cargando en…3
×

Eche un vistazo a continuación

1 de 6 Anuncio

Más Contenido Relacionado

Más reciente (20)

Anuncio

Lecture 6.pptx

  1. 1. UNIT 2: SCOPE RESOLUTION OPERATOR :: CAP202| Dr. Ajay Rastogi | Programming Domain
  2. 2. TO ACCESS A GLOBAL VARIABLE WHEN THERE IS A LOCAL VARIABLE WITH SAME NAME: #include<iostream> using namespace std; int x=10; // Global x main() { int x = 20; // Local x cout << "Value of global x is " << ::x; cout << "nValue of local x is " << x; }
  3. 3. TO DEFINE A FUNCTION OUTSIDE A CLASS. #include<iostream> using namespace std; class lpu { public: void fun(); }; void lpu::fun() { cout << "fun() called"; } main() { lpu a; a.fun(); }
  4. 4. TO ACCESS A CLASS’S STATIC VARIABLES. #include<iostream> using namespace std; class Test { static int x; public: static int y; void func() { cout << "Value of static x is " << Test::x; } }; int Test::x = 1; int Test::y = 2; main() { Test obj; int x = 3 ; obj.func(); cout << "nvalue of static y = " << Test::y; }
  5. 5. FOR NAMESPACE #include<iostream> main() { std::cout << "Hello" << std::endl; }
  6. 6. REFER TO A CLASS INSIDE ANOTHER CLASS: class outside { public: int x=10; void outclass() { cout<<x<<endl; } class inside { public: int y=20; void intclass() { cout<<y<<endl; } }; }; int main() { outside A; A.outclass(); outside::inside B; B.intclass(); }

Notas del editor

  • Insert a map of your country.
  • Insert a map of your country.
  • Insert a map of your country.
  • Insert a map of your country.
  • Insert a map of your country.

×