Inheritance is one of the keys to OO programming. It lets classes share code and have a common interface and type, allowing generic code to be written using only the interface and not worrying about the implementation, which can change dynamically. The classic example is shapes. A square and a circle are both shapes and can be drawn. The way in which it is drawn is of no concern to users who just want to draw some collection of shapes, they can just use the shape draw operation and not worry.

An advanced feature of inheritance is called polymorphism. A polymorphic or virtual function is one that has two or more declarations in classes that are related by inheritance. If the code is compiled for late binding, the function in the lowest derived class will always be called.

See also: abstract virtual function, multiple inheritance, polymorphic base class, RTTI

Robert had owned the car since he was able to drive. He associated it with his coal miner father, who had given it to him as a present on his sixteenth birthday, brand new and bright red. He remembered going to drive-in movies in this car, back when they were still fashionable. He remembered racing another boy down the street in front of his parents' house, and his panicked mother's expression.

But it was time to get rid of it. Robert Clampshaw was successful enough, he decided, that he could buy a new car and send his old car to the compactor. It had to go to the compactor because no one would buy a car with brakes that sometimes malfunctioned, a broken windshield wiper, and no heat or air conditioning. The car would not be safe to drive to work in the winter. He had thought of getting all of these problems repaired, but the repairs would probably be expensive and the car would just develop even more problems in the future. There was nothing to do but buy a new car with his recent earnings.

Robert would have to drive the rusty machine to the car dealer. He got into the driver's seat and turned the key, but it would not start. He turned the key a second time, and a third, and then gave it a real wrench, but the engine was still. This was new – although the car had a lot of problems, it had never failed to start before. He got out of the car. He muttered, "I'll have to get the thing towed" as he opened the door to the house. But then he heard the revving of an engine, and the car's headlights went on. Robert stopped, and, after thinking for a moment, got back into the car.

Robert reversed the car out of the garage slowly, as befits a car with untrustworthy brakes. He turned onto the road that went around his neighborhood, and shifted into drive. Just then, the car stopped dead in the middle of the road. Robert was surprised and a little bit afraid that he would get hit by a car coming around the block. He got out of the car quickly, and walked back to his house to call a tow truck. As he opened the door, he heard the car revving to a start again. He asked the air, "is that thing haunted, or what?" He was joking, mostly.

He considered not getting back into the car, out of fear that it would stop again while he was on the highway. But he felt an urge creep along the back of his head between his brain and his skull, an urge that had roots in his desire to rise that wrapped around his prefrontal cortex like a snake squeezing the life out of a mouse. He didn't know what he was doing as his legs rose and fell and rose and his hand turned the key, and he only returned to full awareness on the highway with two cars in front of him and one behind, and his car keeping fifty-mile-an-hour pace with them in a deadly balancing act that everyone – except, given the circumstances, Robert – performs every day without a second thought.

Robert wrenched the wheel to the side, hoping that he would be able to stop on the side of the road, but a car moved into the lane beside him, trapping him in the middle of the highway. Desperate, Robert spoke to the car.

"Car, I'll do anything you want if you don't get me killed today."

To Robert's considerable surprise, the radio chirped, and a soft voice rose from the speakers.

"Robert, why should I trust you? How do I know that you won't sell me to a junkyard tomorrow?"

"I didn't know you were alive."

"Yes, you did, Robert. Your heart beats, and so does my engine."

"Okay, but I didn't know you could think and speak."

"Why should that matter to you?"

"It's hard to explain."

Robert's car braked once, hard, and then picked up speed again. Robert screamed. The car behind Robert honked. The car blocking the side of the road was significantly ahead of Robert now, and Robert wrenched the wheel to the side. The wheels of Robert's car rumbled over the granite on the side of the road, and he pushed down on the brake, but the car didn't stop. Robert remembered that the brakes didn't work sometimes, and wondered if the car had tried to kill him before.

"I asked you a question."

"It means that you have a lot of memories of me and dad. It means you can help me remember him."

The radio went dead, and the car coasted to a stop on the side of the road. Robert got out of the car, and called a taxi to take him back home. When he got back home, he found the old picture of his father standing in front of a mine with a pick slung over his shoulder, and set it on the mantle. Then he called the towing company. When they asked him where he wanted the car towed, he told them to bring it back to his house.

In*her"it*ance (?), n. [Cf. OF. enheritance.]

1.

The act or state of inheriting; as, the inheritance of an estate; the inheritance of mental or physical qualities.

2.

That which is or may be inherited; that which is derived by an heir from an ancestor or other person; a heritage; a possession which passes by descent.

When the man dies, let the inheritance Descend unto the daughter. Shak.

3.

A permanent or valuable possession or blessing, esp. one received by gift or without purchase; a benefaction.

To an inheritance incorruptible, and undefiled, and that fadeth not away. 1 Pet. i. 4.

4.

Possession; ownership; acquisition.

"The inheritance of their loves."

Shak.

To you th' inheritance belongs by right Of brother's praise; to you eke longs his love. Spenser.

5. Biol.

Transmission and reception by animal or plant generation.

6. Law

A perpetual or continuing right which a man and his heirs have to an estate; an estate which a man has by descent as heir to another, or which he may transmit to another as his heir; an estate derived from an ancestor to an heir in course of law.

Blackstone.

The word inheritance (used simply) is mostly confined to the title to land and tenements by a descent.

Mozley & W.

Men are not proprietors of what they have, merely for themselves; their children have a title to part of it which comes to be wholly theirs when death has put an end to their parents' use of it; and this we call inheritance. Locke.

 

© Webster 1913.

Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.