What does a C++ compiler gets from a compiler?
- Default assignment operator
- Default copy constructor
- Default constructor
- Default destructor
- Size of operator
- Assignment Operator2
Virtual Function:
It is a special function that resolves to the most derived version of the function with the same signature.
Example:
Base *p;
Derived d;
p = &d;
What does new keyword do?class shape { int x; int y; public int findArea(int x, int y) { return x*y; } }
class square extends shape { int x;
public int findArea(int x) { return x*x; }
class rectangle extends shape { }
square s = new square(); int x = 10; int y = 20;
s.findArea(x); //Its own virtual function is called. rectangle r = new rectangle(); r.findArea(x,y); //Base Classes virtual function will be called.
}
It create another instance(new object) of the class. It will allocate space in the memory(heap) for that object;
object o = new object();
No comments:
Post a Comment