answersLogoWhite

0


Best Answer

A data member belongs to an object of a class whereas local variable belongs to its current scope. A local variable is declared within the body of a function and can be used only from the point at which it is declared to the immediately following closing brace. A data member is declared in a class definition, but not in the body of any of the class member functions. Data members are accessible to all member function of the class.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is Difference between local variable and data members or instance variable?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between an array element and a variable?

Array elements are all members of the same variable, indexed in a logical manner. variables are distinct objects which must be referred to distinctly. The main functional difference is that a program can iterate over an array without the programmer knowing the original size of the array or explicitly which member to access.


What Is The difference between between heterosexual and same-sex relationships?

There is only one difference: heterosexual relationships are between members of the opposite sex, and homosexual relationships are between members of the same sex.


What is the difference between static and nonstatic member with example in java?

It depends on whether the member is a static variable or a static method of the class.A non-static member variable is an instance variable. That is, each instance of the class has its own independent set of instance variables.A static member variable is not associated with any one instance of the class, and exists even when there are no instances of the class. As with all static variables, it exists for the entire duration of the program.A non-static member method is an instance method, thus the method automatically inherits a this pointer.A static member method does not inherit a this pointer, but it does have private access to to the class. Thus specific instances can be passed to a static method if necessary.Static members can be thought of as being common to all instances of a class, rather than a specific instance, even though no instances are actually required in order to make use of them.


What is the difference between members and ministers?

ministers get more say


What is the difference between function and operator overloading in c plus plus?

A class is a type while an object is an instance of a class. This can be likened to the way in which an int is a type while an int variable is an instance of an int: int x; // x is an instance of int type. myClass c; // c is an instance of myClass type.


What is the difference between banquet and buffet?

A banquet is restricted to members only.


What is the difference between lateral ties and stirrups?

TIE is to be used for compression members and STIRRUP to be used for flexural members


The defernt between metallica and stanic?

difference is that metallica members are faithful christians.


What is the difference between a captain and crew?

A captain is in charge of the crew members, telling them what to do.


What was the main difference between members of the middle class and members of the lower class?

Access to education, often laws were overlooked by the bourgoisie


What is the difference between members and guest's on Justin's community?

then how do you just view it? Members have accounts and guests are just people visiting/viewing it.


How do you access structure member?

we can access and assign values of the members of a structure in a number of ways. as mentioned earlier, the members themselves are not variables .they should be linked to the structure variables in order to make them meaningful members . for example the word title , has no meaning whereas the phrase 'title of book3' .the link between a members and a variable is established using the members operator '.' which is also known as 'dot operator ' or ' period operator '.for example , book.priceis the variable representing the price of book1 and can be treated like any other ordinary variable