Why static functions always uses static variables?

Answers were Sorted based on User's Feedback



Why static functions always uses static variables?..

Answer / george from psg

static function is constant to all object. In the same way
static variable is constant to all so we use static variable
in static function

Is This Answer Correct ?    9 Yes 1 No

Why static functions always uses static variables?..

Answer / som shekhar

If you take in the context of the class, static member
functions cannot be called by the ordinary objects because
when normal object calls the function then address of the
object is passed is collected by "this" pointer and static
member function don't have "this" pointer.

Is This Answer Correct ?    0 Yes 0 No

Why static functions always uses static variables?..

Answer / harsha

context,object are created in RAM. context is created
once.static methods implementaion , static varibles loads
into context only once.All those staic members avilable to
each other obviously.

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More OOPS Interview Questions

What is polymorphism ? Explain with examples

8 Answers   Ness Technologies,


what is different between oops and c++

0 Answers   IIT,


Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer

0 Answers  


pointers are support in C#? if yes then how to use it?

8 Answers   Softvision Solution,


Why static Function is used in C++?

4 Answers   TCS,






How does polymorphism work?

0 Answers  


What is the difference between abstraction and polymorphism?

0 Answers  


What are the fields of vtable

1 Answers   Mphasis,


Write a program to find out the number of palindromes in a sentence.

1 Answers   TCS,


what is SPL in c++.

1 Answers  


1.explicit call for destructor 2.calling function inside a constructor. 3.base *b-new derived delete b; 4.delete p what it will delete. 5.size of base class and derived class int i,in base class and int j in derived. 6.int i-20 int main() { int i =5; printf("%d".::i); { int i =10; printf("%d".::i); } } 7.object slicing 8.new 9.function overloading(return type). 10.class base() { virtuval fun() { ----- } } class derivied:public base() { fun() { ----- } } int main() { derived d; } 11.how static function will call in C++? 12.default structures are in C++? 13.constructors should be in public . 14.virtuval constructor not exist. 15.multilevel inhritence. destructor order.

1 Answers   Tech Mahindra,


• What are the desirable attributes for memory managment?

0 Answers  


Categories