What is static function and static class?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
Write is a binary search tree? Write an algo and tell complexity?
Write a program in c++ to print the numbers from n to n2 except 5 and its multiples
What is c++ used for in games?
Does c++ have a hash table?
What is the basic structure of a c++ program?
What are stacks?
What is the difference between global variables and local variable
What you know about structures in C++?
0 Answers Agilent, ZS Associates,
Is it possible for a member function to use delete this?
How do you find out if a linked-list has an end? (I.e. The list is not a cycle)
Explain rethrowing exceptions with an example?
What is a string example?