Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 08-01-2011
Member
 
Join Date: Dec 2010
Posts: 16
Scope of Object or variable in Object oriented Programming Languages

Hey Friends, I wanted to know about the scope of object and variable in object oriented programming languages. In my college I was not able to understand this term which I think is very much important to understand. This term is in other object oriented languages. So, anybody who is aware of the above solution please let me know as soon as possible. It would be better if the term is explained with proper example.
Reply With Quote
  #2  
Old 08-01-2011
Member
 
Join Date: Apr 2009
Posts: 567
Re: Scope of Object or variable in Object oriented Programming Languages

Scope is the largest region of program text in which an object or variable can be potentially used in the program. The scope of a variable or object is nothing but its visibility in the program. It is the mechanism by which it is possible to limit the visibility of an object or variable in a program. Once the scope of an object ends the visibility of the object also ends and the object is destroyed by the C++ and memory is recollected from the object.
Reply With Quote
  #3  
Old 08-01-2011
Member
 
Join Date: Apr 2009
Posts: 484
Re: Scope of Object or variable in Object oriented Programming Languages

For example
#include<iostram.h>
Line 1 main()
Line 2 {
Line 3 Box b1;
Line 4 {
Line 5 Box b2;
Line 6 }
Line 7 {
Line 8 Box b3;
Line 9 }
Line 10 }

Just observe the above program, The object b1 is created at line 3 so its scope will be throughout the program (up to line 10),The object b2 is created at line no 5 and it is in the curly brace which starts from line no 4 and ends at line no 6.So scope of b2 will be only in between line no 4 -6.As soon as the control of program will come out of line no 6 the object b2 will be destroyed by C++ as its scope ends. The same thing will happen with object b3.The scope of object b1 will end at line no.10.
Reply With Quote
  #4  
Old 08-01-2011
Member
 
Join Date: May 2009
Posts: 523
Re: Scope of Object or variable in Object oriented Programming Languages

Well you should that in object oriented programming languages once the object are destroyed then the scope of its object is also destroyed. Then that object won?t be available in the program. Scope of object or variable can said as lifetime of an object or variable. So, one should know that once the object or variable is destroyed then it access and visibility is also over.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Scope of Object or variable in Object oriented Programming Languages"
Thread Thread Starter Forum Replies Last Post
Object oriented programming with java cloud101 Software Development 2 22-02-2012 01:11 AM
What are the different types of Object Oriented Programming Languages? fLUTE Software Development 4 11-07-2011 02:39 PM
what is message passing and other terms in Object oriented programming languages? Palnila Software Development 3 08-01-2011 06:23 AM
static methods in object oriented programming Satchel Software Development 5 07-01-2011 09:58 PM
The OOP Object Oriented programming Concept & its principle? Bhavya Software Development 3 25-02-2009 09:16 PM


All times are GMT +5.5. The time now is 12:39 AM.