answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: What are the typical problems with Aston Martin DB9s?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What do you mean by inheritance . give example from c plus plus?

Inheritance in C++ is where you derive a new object from an existing object. The derived object is simply a more specialised version of the original object. The existing object could be a generic car object from which we could derive a more specific type of car such as the Aston Martin DB9. Moreover, if we have a DB9 object then we could just as easily derive an even more specific DB9 such as the Aston Martin DBR9.In other words, the DB9 inherits all the properties that we might associate with a car, such as a chassis, 4 road wheels, a steering wheel, an engine and gearbox, and a body. By the same token, the DBR9 inherits all the properties of a DB9 (and therefore all the properties of a car), retaining the chassis, engine block and cylinder heads from the DB9 whilst adding high performance components elsewhere.This is, of course, an over-simplification. But when we model the real-world within a computer we never model the real-world in minute detail, we only model part of the real-world (and usually just a minuscule part of it), and only in as much detail as we need in order to solve a problem. For instance, if we wished to model traffic flow through a city, we don't necessarily need to know how many DB9s are passing through. That "a car" passed through is probably all we need to know. But that car could be derived from a more generic "road-vehicle" object, which would then allow us to model buses, trucks, motorbikes and push bikes.When modelling the real-world it's important to identify early on which objects are real and which are purely conceptual. In our DB9 example, the car object is best described as being a purely-conceptual object -- an abstraction -- but in our traffic flow model that same car could be a real object. Or it could be conceptual if we wished to distinguish between petrol, diesel, electric and hybrid cars.In C++ there are several inheritance models. Single inheritance is fairly straightforward and describes how one type of object is directly derived from another type of object. When discussing the type of an object we are referring explicitly to its class, and it is the class that defines the type of inheritance.Multiple inheritance describes how one class is directly derived from two or more distinct classes. You might use this type of inheritance when describing a hybrid car, since it is derived from both a petrol and an electric car. Or an amphibious landing craft which is both a car and boat.Multi-level inheritance occurs when a generic class is also a derived class. In our DB9 example, the DB9 is generic with respect to the DBR9, but also derived with respect to the car. Most of the time this is of little concern since the derived object is only really concerned with the generic class or classes from it was directly derived. However, occasionally it leads to an inheritance model that can sometimes be problematic if not handled correctly: virtual inheritance.Virtual inheritance describes the way in which a derived object inherits from two or more generic objects, and those generic objects are themselves derived from a common generic object. Going back to our hybrid example, we can see how this works in the real-world. Our hybrid car obviously inherits from both a petrol and an electric car, but both of these could inherit from the generic car. The problem is that this means there are two instance of the generic car within our hybrid, but the hybrid is just one car. When we refer to the car class directly from our hybrid, there is ambiguity because there's no way to determine which instance of car we are actually referring to. Virtual inheritance gets around this ambiguity by allowing both petrol and electric cars to inherit from car virtually, rather than directly.What this means is that our hybrid (and any derivative of hybrid) inherits directly from one instance of car, while our electric and petrol cars both share this one instance, virtually. An electric car, by itself, will still inherit directly from car, as will a petrol car, since they are both the most-derived classes in those specific models, but our hybrid or any derivative of hybrid renders the car a virtual class. With only one instance of car, all ambiguity is removed.Now that we've discussed how inheritance works in principal, we can examinethe ways in which we can modify access to the generic class members with respect to the derived class. Inheritance may be done with private, protected or public access. When not explicitly stated, the default is private access for classes and public access for structs (exactly the same as would apply to the class member access specifiers). Regardless of the access specified via inheritance, derived classes always inherit all the public and protected members of their generic classes. All we're really doing is modifying their visibility with respect to the derived class. However, private members of the generic class are never inherited, and we can never elevate access, we can only keep it the same, or reduce it. Any member with greater access to the specified access will be reduced to the specified access. Thus if we specify public access, all generic members maintain their current access. If we specify protected access, all public members of the generic class become protected members of the derived class. And with private access, all public and protected members become private members of the derived class.Normally we will alter the access via the inheritance declaration itself, which applies to the generic class as a whole. However, we can also modify the access to individual members, simply be redeclaring them with the new access type, thus giving us fine granular control over every public and protected member that is inherited.The following code examples demonstrate some of the principals thus far described.class A {};class B : public A {}; // single inheritanceclass C : public B {}; single-inheritance, multi-levelclass D : virtual public C {}; virtual single inheritance, multi-levelclass E : virtual public C {}; virtual single inheritance, multi-levelclass F: public D, public E {}; virtual multi-inheritance, multi-levelAll these examples are non-functional since the declarations have been left empty. However, they describe the bare essentials required of inheritance. All access to the generic classes is declared public, so there would be no changes to how the base class members are accessed with respect to the derived class.Most classes that are intended to act as generic classes will include one or more virtual methods (virtual functions). This simply means that derivatives are expected to override those methods as required in order to provide a more specific implementation. If the generic implementation suffices, there is no need to override it. However, it's important to remember that if there is one or more virtual functions in the generic class, the generic class destructor must also be virtual.When a generic class is intended to act as a conceptual class or an abstract data type, then it must have at least one pure-virtual method. What this means is that the derived class must override all pure-virtual methods otherwise it becomes an abstract class itself. Once a derivative implements an override, that override reverts to being a virtual method which can subsequently be inherited, even if the the derived class remains abstract. The generic abstract class may or may not provide implementations for its pure-virtual methods, but any that are provided cannot be inherited (only the signature is inherited), and can only be called explicitly via a derived class override. Note that abstract base classes cannot be instantiated by themselves -- remember they are conceptual objects, not actual objects. They can only be instantiated through inheritance and only by providing (or inheriting) a complete implementation of the abstract interface.To understand abstraction, consider a shape object. There is no such thing as a shape, there are only types of shape. Thus a shape is the concept of an object, whereas a circle, square or triangle are the physical embodiment of shape objects, and therefore inherit all the properties of shape; everything that is common to all shapes such as vertices, colour, a bounding rectangle (which is itself a shape), and so on. To use another analogy, a mammal is a conceptual object whereas a Golden Labrador is a specific type of mammal. Depending on the amount of detail you require in your model, a dog could be considered an actual object if you weren't interested in specific types of dogs, or conceptual if you were. If you were only interested in mammals and reptiles, then animal objects would be considered conceptual. And so on.