Answer Posted / madhu
In C++ when you declare and define a static variable, it
tells the compiler that only one copy of memory will be
allocated and all the objects of that class will share that
copy.
As we know for class data variables memory will be created
independently for every object of that class. and we can
access the data using object. But, for static variables
memory is created only once for all objects and is no object
is owned the static variable. we can access the static
variable using class name.
Mainly static variables are used when want to count the
objects created and destroyed and when we are dealing with
singleton design pattern.
| Is This Answer Correct ? | 10 Yes | 0 No |
Post New Answer View All Answers
program for insertion ,deletion,sorting in double link list
write a C++ program for booking using constructor and destructor.
What are the 5 oop principles?
What is encapsulation and abstraction? How are they implemented in C++?
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
what type of question are asked in thoughtworks pair programming round ?
write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.
Can abstract class have normal methods?
Is this job good for future? can do this job post grduate student?
I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...
What type of loop is a for loop?
Can a destructor be called directly?
How does polymorphism work?
Which language is not a true object oriented programming language?
Which method cannot be overridden?