When is a memory allocated to a class?
Answers were Sorted based on User's Feedback
Answer / vineet makkar
The answer to this question lies in the basic difference
between
OBJECT & INSTANCE
INSTANCE : Refers to a reference of an object, it can be
null.
OBJECT: Actually pointing to the memory address of that
instance.
eg
Student stdnt; // Instance is created
Student stdnt = new Student; // Object is created
So, in short, memory is allocated to a class when the
object of the class is created using "new" keyword.
| Is This Answer Correct ? | 26 Yes | 3 No |
Answer / ramakrishna
A class is a template.As Teginder said,it will get
allocated memory when u create object of that class.
| Is This Answer Correct ? | 22 Yes | 5 No |
Answer / achal
when an object of that class is created and constructor
runs. memory is allocated in Stack (part of RAM)
| Is This Answer Correct ? | 13 Yes | 3 No |
Answer / anumohan
when instance of that class is created by creating object
to the class
| Is This Answer Correct ? | 11 Yes | 3 No |
Answer / namrata ahuja
when the object of that class is declared.
| Is This Answer Correct ? | 7 Yes | 5 No |
Answer / saurabh
when we create the data member of the class by using d syntax
class
{
static int a;
};
static int a;
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / x
It is allocated compile-time unless we are using new and
delete functions
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / sourav das
when object is created of that class then only memory is
allocated.with out object there is no Existence of class.
| Is This Answer Correct ? | 0 Yes | 0 No |
How oops is better than procedural?
What is use of overloading?
In multilevel inheritance constructors will be executed from the .... class to ... class
What is R T T I ?
How do you explain polymorphism?
#include <iostream> using namespace std; struct wow { int x; }; int main() { wow a; wow *b; a.x = 22; b = &a; a.x = 23; cout << b->x; return 0; }
You attempt to query the data base with this command: SELECT name, salary FROM employee WHERE salary=(SELECT salary FROM employee WHERE last name='Wagner' OR dept no=233) Choose most appropriate option from the following: 1)Sub-queries are not allowed in the where clause. 2)a multiple row sub-query used with a single row comparison operator. 3)a single row query is used with a multiple row comparison operator.
Why do we use oops?
How do you make derived class as an abstract class?
What Is a Polymorphism? How many types of polymorphism and whats that use in application?
What is a friend function & its advantage?
What is class in oop with example?