ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  C++ General
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
What is the use of static functions?
 Question Submitted By :: Shalini
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the use of static functions?
Answer
# 1
they are not associated with "this" pointer since it can be 
called without object.they can acees only static varibales.
 
Is This Answer Correct ?    0 Yes 0 No
Dee
 
  Re: What is the use of static functions?
Answer
# 2
static word meaning it cannot be changed.so when we use 
static in the function it cannot be changed
 
Is This Answer Correct ?    1 Yes 0 No
Priya
 
 
 
  Re: What is the use of static functions?
Answer
# 3
Static function is basically used in creating factory 
objects.
You can make your constructor private and expose static 
function. And user can use the static methods to create the 
object of that class.
Using NONSHARABLE_CLASS you can restrict the usage of 
static functions/method also.
 
Is This Answer Correct ?    0 Yes 0 No
Reejusri
[********]
 
  Re: What is the use of static functions?
Answer
# 4
If we r using Static functions all the objects will get only
a single copy of dat function,means der wil b only one copy
of dat function.
static functions will contain only static variables.
 
Is This Answer Correct ?    0 Yes 0 No
Sanish Joseph
 
  Re: What is the use of static functions?
Answer
# 5
A static function member can be used to provide utility
functions to a class. For example, with a class representing
calendar dates, a function that tells whether a given year
is a leap year might best be represented as a static
function (DateTime.IsLeapYear). The function is related to
the operation of the class but doesn't operate on particular
object instances (actual calendar dates) of the class.
 
Is This Answer Correct ?    1 Yes 0 No
Anh Vu
 
  Re: What is the use of static functions?
Answer
# 6
The differences between a static member function and non-
static member functions are as follows.

A static member function can access only static member 
data, static member functions and data and functions 
outside the class. A non-static member function can access 
all of the above including the static data member.

A static member function can be called, even when a class 
is not instantiated, a non-static member function can be 
called only after instantiating the class as an object.

A static member function cannot be declared virtual, 
whereas a non-static member functions can be declared as 
virtual

A static member function cannot have access to the 'this' 
pointer of the class.
The static member functions are not used very frequently in 
programs. But nevertheless, they become useful whenever we 
need to have functions which are accessible even when the 
class is not instantiated.
 
Is This Answer Correct ?    0 Yes 0 No
V Venkatesh
 

 
 
 
Other C++ General Interview Questions
 
  Question Asked @ Answers
 
wrong statement about c++ a)code removably b)encapsulation of data and code c)program easy maintenance d)program runs faster  8
What are the differences between a struct in C and in C++? Wipro4
What are the different types of Storage classes?  3
if i want cin 12345678910 and cout abcdefghij. so how can i create the program?. example : if i key in 8910 so the answer is ghij.  3
Explain the need for "Virtual Destructor"? Infosys1
What is the difference between a copy constructor and an overloaded assignment operator? Microsoft3
What are the basics of classifying different storage types, why? Symphony2
what is meaning of isa and hsa  1
Describe functional overloading? HP3
What is the difference between Class and Structure? HP2
What happens if an exception is throws from an object's constructor and from object's destructor? TCS2
why the size of an empty class is 1  3
1. What does the following do: void afunction(int *x) { x=new int; *x=12; } int main() { int v=10; afunction(&v); cout<<v; } a) Outputs 12 b) Outputs 10 c) Outputs the address of v Quark3
1)#include <iostream.h> int main() { int *a, *savea, i; savea = a = (int *) malloc(4 * sizeof(int)); for (i=0; i<4; i++) *a++ = 10 * i; for (i=0; i<4; i++) { printf("%d\n", *savea); savea += sizeof(int); } return 0; } 2)#include <iostream.h> int main() { int *a, *savea, i; savea = a = (int *) malloc(4 * sizeof(int)); for (i=0; i<4; i++) *a++ = 10 * i; for (i=0; i<4; i++) { printf("%d\n", *savea); savea ++; } return 0; } The output of this two programs will be different why?  2
implement stack using stack.h headerfile functions Subex1
Explain "passing by value", "passing by pointer" and "passing by reference" ?  5
what is data Abstraction? and give example TCS13
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. Quark2
Can we use resume in error handling i.e. in the catch block Infosys3
Why is it difficult to store linked list in an array? Lucent2
 
For more C++ General Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com