What is static function and static class?

Answers were Sorted based on User's Feedback



What is static function and static class?..

Answer / anthony michael

Static function and static variable does not below to single
instance of a class.

To access static functions we don't need instance of a class
instead it can be accessed using the class name followed by
::operator as:
[class_name::static_function() ]

Is This Answer Correct ?    8 Yes 2 No

What is static function and static class?..

Answer / anthony michael

Sourisengupta

Static Class is not possible in C++. But it can be done in
Managed C++

Static Class:
For Static Class we can't create Instances and It can only
hold Static member's.

Creating a static class is therefore much the same as
creating a class that contains only static members and a
private constructor. A private constructor prevents the
class from being instantiated.

Is This Answer Correct ?    5 Yes 1 No

What is static function and static class?..

Answer / brainless

If compilers don't check your pointers strictly,
you can also write code as below,

class A
{
//some static function code here
//never access non-static attributes here
static void callMe() {}
};

int main()
{
A * inst = NULL;
(*inst).callMe();
}

Is This Answer Correct ?    1 Yes 2 No

What is static function and static class?..

Answer / sourisengupta

Anthony,

I got what is static function..but still waiting for the
definition of static class.

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More C++ General Interview Questions

What are advantages and disadvantages of Design patterns?

7 Answers   IBM, Vodafone,


Write about the role of c++ in the tradeoff of safety vs. Usability?

0 Answers  


What are c++ tokens?

0 Answers  


What are the types of array in c++?

0 Answers  


Describe delete operator?

0 Answers  






class X { private: int a; protected: X(){cout<<"X constructor was called"<<endl;} ~X(){cout<<"X destructor was called"<<endl} }; Referring to the code above, which one of the following statements regarding "X" is TRUE? a) X is an abstract class. b) Only subclasses of X may create X objects. c) Instances of X cannot be created. d) X objects can only be created using the default copy constructor. e) Only friends can create instances of X objects.

2 Answers   Quark,


How is data hiding achieved in c++?

0 Answers  


Difference between Top down and bottom up approaches for a given project ?

14 Answers   BSNL, CSC, HCL, HP, IIT, Infosys, Siemens,


what is data Abstraction

2 Answers  


How do you decide which integer type to use?

0 Answers  


Does defining a function inline mean that it wont push and pop things on/off the stack ...like parameters and the return the address??

2 Answers  


Define a way other than using the keyword inline to make a function inline?

1 Answers  


Categories