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 is abstraction with real time example?

0 Answers  


Write the program for fibonacci in c++?

20 Answers   TATA, Wipro,


Can we run c program in turbo c++?

0 Answers  


Can we delete this pointer in c++?

0 Answers  


Differentiate between a template class and class template?

1 Answers  






What is the purpose of ios::basefield in the following statement?

0 Answers  


What is pure virtual function? Or what is abstract class?

0 Answers  


Consider the following code fragment: int main(void) { int m = 4; mystery ( m ); mystery ( m ); printf("%d", m); return 0; } What is the output on the monitor if mystery is defined as follows ? void mystery (int m) { m = m+3; }

2 Answers   CDAC, Wipro,


Write a program and call it sortcheck.cpp which receives 10 numbers from input and checks whether these numbers are in ascending order or not. You are not allowed to use arrays. You should not define more than three variables

2 Answers   BirlaSoft, Crayonz,


What is copy constructor? Can we make copy constructor private in c++?

0 Answers  


What does namespace mean in c++?

0 Answers  


What is the use of structure in c++?

0 Answers  


Categories