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

Explain rethrowing exceptions with an example?

0 Answers  


Is the declaration of a class its interface or its implementation?

0 Answers  


Can we overload operator in c++?

0 Answers  


Describe the advantages of operator overloading?

0 Answers  


What are inline functions? What is the syntax for defining an inline function?

0 Answers  






If you push the numbers (in order) 1, 3, and 5 onto a stack, which pops out first a) 1 b) 5 c) 3

0 Answers  


What are the static members and static member functions?

1 Answers  


How a new element can be added or pushed in a stack?

0 Answers  


write a c++ program to create class student having datamember name,Roll_no,age,and branch intilcization all the member using constructor print the all the details on the screen.

0 Answers  


What return value must conversion operators have in their declaration?

0 Answers  


What is rvalue?

0 Answers  


How do you sort a sort function in c++ to sort in descending order?

0 Answers  


Categories