answersLogoWhite

0


Best Answer

It is called Inheritance

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: It allows the creation of a new class from a base class?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What allows a new class to automatically pick up all the data and methods of an existing class?

Inheritance allows a new class to automatically pick up all the protected and public data and methods of an existing class. To do so, the new class must be derived from the existing class. Private data and methods remain private to the existing class, the base class.


What Allows the creation of new markets?

Trade


What allows creation in new markets?

Trade <3APEX<3


What allows creation in a new market?

Trade <3APEX<3


What is object in java programming?

In java object is an instance of a class. Objects are created using the new keyword. When you use the new keyword along with a class name, an object of that class would get created. Ex: Ferrari obj = new Ferrari(); Here a new object of Ferrari gets created. A constructor of the class Ferrari would get invoked during the object creation.


When was The New Creation created?

The New Creation was created in 1940.


What is the creation of new offspring?

Reproduction is the term for the creation of new offspring.


How you can override base class member in derived classexplain with example?

To override a base class method you simply need to declare the base class method as being virtual. As well as creating a v-table, this also gives a visual hint to other developers that you expect the function to be overridden. The v-table ensures that all calls to the base class method are routed to the derived class method, thus ensuring objects behave polymorphically, according to their actual type, and not what we're actually pointing at. Consider the following example: #include <iostream> class base { public: virtual ~base(); virtual void PrintMe() const { std::cout << "I am a base class!" << std::endl; } }; class derived: public base { public: void PrintMe() const { std::cout << "I am a derived class!" << std::endl; } }; int main() { base b; derived d; base* pb = &d; b.PrintMe(); d.PrintMe(); pb->PrintMe(); return( 0 ); } Output: I am a base class! I am a derived class! I am a derived class! Note that although pb points to the base class instance of d, it still knows that it really is a derived class, as can be seen from the third line of output. Now try removing the virtual keyword from the base class method. The output will change as follows: Output: I am a base class! I am a derived class! I am a base class! Now your derived class thinks it is a base class. This is because the v-table no longer has no entry for that method, and therefore the call cannot be routed to the overridden derived class method. The base class method is called because that's what we're actually pointing at and the object no longer behaves polymorphically according to its actual type. Note also that if any method is declared virtual in a class, the class constructor must also be declared virtual. If you fail to do this, your classes will not be destroyed properly. The virtual keyword ensures that the most-derived class is always destroyed first, before working up the hierarchy of destructors to eventually destroy the least-derived class, the base class itself. Consider the following example without a virtual destructor: #include <iostream> class base { public: base(){ std::cout << "Base class created" << std::endl; } ~base(){ std::cout << "Base class destroyed" << std::endl; } }; class derived: public base { public: derived(){ std::cout << "Derived class created" << std::endl; } ~derived(){ std::cout << "Derived class destroyed" << std::endl; } }; int main() { derived* d = new derived(); base* b = d; delete( b ); return( 0 ); } Output: Base class created Derived class created Base class destroyed As you can see, the derived class was created but was not destroyed. We've created a memory leak: that memory cannot be recovered until the program ends. Now add the virtual keyword to the base class destructor: #include <iostream> class base { public: base(){ std::cout << "Base class created" << std::endl; } virtual ~base(){ std::cout << "Base class destroyed" << std::endl; } }; class derived: public base { public: derived(){ std::cout << "Derived class created" << std::endl; } ~derived(){ std::cout << "Derived class destroyed" << std::endl; } }; int main() { derived* d = new derived(); base* b = d; delete( b ); return( 0 ); } Output: Base class created Derived class created Derived class destroyed Base class destroyed Now we have the expected behaviour and have resolved the memory leak. Remember, if ANY method of a class is declared virtual, the destructor must also be declared virtual. Note that although derived classes need not use the virtual keyword in front of overrides (it is implied by the base class), there is no harm in explicitly declaring them as such, if only to give a visual hint that the methods are expected to be overridden by derivatives of the derivative (multi-level inheritance).


When to use inheritance in c plus plus?

You use inheritance whenever you need a more specialised version of an existing class (the base class). Rather than creating a new class entirely from scratch, and therefore duplicating tried and tested code, you simply build upon the existing class, overriding the existing methods and adding more specialised methods, whilst retaining all the generic functionality of the base class.


When was New Creation Church created?

New Creation Church was created in 1984.


Can a friend function of derived class access private data of base class?

In some computer languages it is possible to do so, but I would not even think or design any application in this way. A base class SHOULD NEVER know what the derived classes are. Perhaps it was created by generalizing some classes. Even at that point, this new base class should have no knowledge of the derived classes whatsoever. To do a good OO design, the base class should have a method like getPrivatePartOfDerivedClass() as abstract, then force the derived class to provide the implementation of this method.


What is new in automotive technology?

AI or Artificial Intelligence is what allows some machines to think like a human. This allows for the creation of a lot of tech products like virtual assistants like Siri on iOS or Google Assistant on Android.