Interview Questions   Tutorials   Discussions   Programs   Videos   

C++ - What is difference between static and non-static variables

asked marvit August 18, 2014 12:54 PM  

What is difference between static and non-static variables


1 Answers

answered By bhjahnavi   0  
Static Variables:
A static variable is associated with the class has only one copy per class but not for each object. An instance of a class does not have static variables.
Static variables can be accessed by static or instance methods
Memory is allocated when the class is loaded in context area at run time.
Non-Static Variables:
Non-static variables will have one copy each per object. Each instance of a class will have one copy of non-static variables.
Instance variables can be accessed only by the instance methods.
Instance variables are allocated at compile time.
   add comment

Your answer

Join with account you already have



Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!