Why for local variables the memory required to hold the
variable is allocated from the program stack and for new
its allocated from the heap?
Answer / achal ubbott
* Stack is a kind of data structure where Last In FirstOut
work. Local variables are needed for a short span of time
for immediate processing. So push and pop from stack is
used for them. Now memory is allocated to them in static
time only.
* new() operator allocates memory dynamically. Since
objects are needed for more time, space is taken from heap.
Is This Answer Correct ? | 2 Yes | 0 No |
What are protected members in c++?
What is the first name of c++?
Please explain class & object in c++?
explain the reference variable in c++?
Can member functions be private?
What is the return value of the insertion operator?
class Alpha { public: char data[10000]; Alpha(); ~Alpha(); }; class Beta { public: Beta() { n = 0; } void FillData(Alpha a); private: int n; }; How do you make the above sample code more efficient? a) If possible, make the constructor for Beta private to reduce the overhead of public constructors. b) Change the return type in FillData to int to negate the implicit return conversion from "int" to "void". c) Make the destructor for Alpha virtual. d) Make the constructor for Alpha virtual. e) Pass a const reference to Alpha in FillData
Difference between Abstraction and encapsulation in C++?
Is there a datatype string in c++?How is the memory allocation?
Why is that unsafe to deal locate the memory using free( ) if it has been allocated using new?
How to construct virtual constructor
6 Answers CIStems Software, Symphony,
class base { public: int fun(int) {} }; class base2 { public: int fun(float) { } }; so here qustion is both function either function overloading or over riding;