Manhattan associates Interview Question
Software Engineer / DevelopersCountry: India
Interview Type: In-Person
static member functions can be accessed without creating instance or object of the class.
For ex:
class xyz
{
private:
static int a;
public:
static int fun(void)
{
a=5;
return a;
}
};
int main()
{
cout<<"value of static member a:"<<xyz::fun();
return 0;
}
The static members and member functions do not take part in memory allocated to object or instance of a class. Static variables are kind of global variables having one copy shared among all objects of the class.
Static members or member functions stored in BSS memory where as other non static member functions are stored in heap or stack.
static member functions can be accessed without creating instance or object of the class.
For ex:
class xyz
{
private:
static int a;
public:
static int fun(void)
{
a=5;
return a;
}
};
int main()
{
cout<<"value of static member a:"<<xyz::fun();
return 0;
}
The static members and member functions do not take part in memory allocated to object or instance of a class. Static variables are kind of global variables having one copy shared among all objects of the class.
Static members or member functions stored in BSS memory where as other non static member functions are stored in heap or stack.
static member functions can be accessed without creating instance or object of the class.
For ex:
class xyz
{
private:
static int a;
public:
static int fun(void)
{
a=5;
return a;
}
};
int main()
{
cout<<"value of static member a:"<<xyz::fun();
return 0;
}
The static members and member functions do not take part in memory allocated to object or instance of a class. Static variables are kind of global variables having one copy shared among all objects of the class.
Static members or member functions stored in BSS memory where as other non static member functions are stored in heap or stack.
static member functions can be accessed without creating instance or object of the class.
For ex:
class xyz
{
private:
static int a;
public:
static int fun(void)
{
a=5;
return a;
}
};
int main()
{
cout<<"value of static member a:"<<xyz::fun();
return 0;
}
The static members and member functions do not take part in memory allocated to object or instance of a class. Static variables are kind of global variables having one copy shared among all objects of the class.
Static members or member functions stored in BSS memory where as other non static member functions are stored in heap or stack.
static member functions can be accessed without creating instance or object of the class.
For ex:
class xyz
{
private:
static int a;
public:
static int fun(void)
{
a=5;
return a;
}
};
int main()
{
cout<<"value of static member a:"<<xyz::fun();
return 0;
}
The static members and member functions do not take part in memory allocated to object or instance of a class. Static variables are kind of global variables having one copy shared among all objects of the class.
Static members or member functions stored in BSS memory where as other non static member functions are stored in heap or stack.
Both static member functions and non-static member functions will be stored in Code Segment of the program. When the program is loaded into memory bss does not exist at all. Only the uninitialized global variables will reside in program bss. Once the process is loaded to memory all bss variables will be initialized to zero and gets loaded to memory. so the answer for this question is any member function will be stored on Code Segment of the process and this code is shared for all the objects
Both static member functions and non-static member functions will be stored in Code Segment of the program. When the program is loaded into memory bss does not exist at all. Only the uninitialized global variables will reside in program bss. Once the process is loaded to memory all bss variables will be initialized to zero and gets loaded to memory. so the answer for this question is any member function will be stored on Code Segment of the process and this code is shared for all the objects
static has different meanings depending on what you are talking about - variables, classes, functions, etc...
In regards to functions, the static keyword does not affect storage at all but is rather simply a guide to the linker stating that only other functions in the source file where the static function is defined may call it. Declaring a function static simply makes the linker enforce this rule and error will result if you try to circumvent the rule. So, that said, the code for the function exists in the text/code portion along with all the other code.
Static methods are the methods that gives you a global point of access for a particular interface(behavior). Both the static and non-satic methods are stored in Code/Text section of the object code which is shared by the instances of program
Pls write if i am wrong!!..
Stored in bss section of memory
- Abhishek February 06, 2012