CSC/ECE 517 Fall 2012/ch1 1w23 as: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:


==Multiple Inheritance==
==Multiple Inheritance==
Multiple Inheritance is a technique of establishing hierarchical relationships within a set of classes, such that a single class can inherit  behaviors from multiple parent classes. Although it might seem useful, to include methods from multiple classes, the major issue with multiple inheritance is the ambiguity in referencing the parent class methods,  when more than one parent classes share a method with the same name.This ambiguity is predominant in cases where the inheritance hierarchy is more than one level deep, where the class in the lowermost level inherits from two classes, that have overridden the same method from their parent in different ways.Now the class in the lowermost level has two different implementations of its grand-parent’s method resulting in an ambiguous situation, which is otherwise called as the [[Deadly Diamond of Death problem]].
Multiple Inheritance is a technique of establishing hierarchical relationships within a set of classes, such that a single class can inherit  behaviors from multiple parent classes. Although it might seem useful, to include methods from multiple classes, the major issue with multiple inheritance is the ambiguity in referencing the parent class methods,  when more than one parent classes share a method with the same name.This ambiguity is predominant in cases where the inheritance hierarchy is more than one level deep, where the class in the lowermost level inherits from two classes, that have overridden the same method from their parent in different ways.Now the class in the lowermost level has two different implementations of its grand-parent’s method resulting in an ambiguous situation, which is otherwise called as the Deadly Diamond of Death problem.


==A Real World Example==
==A Real World Example==

Revision as of 02:07, 12 September 2012

1w23: Multiple Inheritance and Mixins

Introduction

Multiple Inheritance

Multiple Inheritance is a technique of establishing hierarchical relationships within a set of classes, such that a single class can inherit  behaviors from multiple parent classes. Although it might seem useful, to include methods from multiple classes, the major issue with multiple inheritance is the ambiguity in referencing the parent class methods,  when more than one parent classes share a method with the same name.This ambiguity is predominant in cases where the inheritance hierarchy is more than one level deep, where the class in the lowermost level inherits from two classes, that have overridden the same method from their parent in different ways.Now the class in the lowermost level has two different implementations of its grand-parent’s method resulting in an ambiguous situation, which is otherwise called as the Deadly Diamond of Death problem.

A Real World Example

Issues of Multiple Inheritance

Headings organize your writing into sections. The wiki software can automatically generate a table of contents from them. Start with 2 'equals' ("==") characters. Let us consider a real world example of representing players of Cricket using classes and instances. The players of Cricket are instances of class Cricketer. Classes Bowler and Batsman inherit Cricketer’s state and behavior. All rounders inherit states and behaviors of Batsman, Bowler and subsequently from the Cricketer through Batsman and Bowler classes. Let us explore the issues of multiple inheritance in reference to this context.


Subsection

Using more 'equals' characters creates a subsection.

A smaller subsection

Don't skip levels, like from two ("==") to four ("====") 'equals' characters.

A defined term
A semicolon at the

start of a line is a way of making a definition where the word being defined appears in bold. The definition itself follows the colon and is not rendered bold by default. It is not a heading and does not appear in the table of contents.

Lists

  • Unordered lists are easy to do:
    • Start every line with a star.
      • More stars indicate a deeper level.
      Previous item continues.
    • A new line
  • in a list

marks the end of the list.

  • Of course you can start again.
  1. Numbered lists are:
    1. Very organized
    2. Easy to follow
    Previous item continues

A new line marks the end of the list.

  1. New numbering starts with 1.

Format

Text formatting

Description What you type What it looks like

Italics, bold, Template:Smallcaps.

To ''italicize text'', just put
2 apostrophes on each side.

3 apostrophes will '''bold the text'''

5 apostrophes for '''''bold italics'''''

For text as {{Smallcaps|small caps}},
that uses a [[Help:Template|template]].

To italicize text, just put 2 apostrophes on each side.

3 apostrophes will bold the text

5 apostrophes for bold italics

For text as Template:Smallcaps, that uses a template.

Small chunks of source code within a line of normal text.

Code is displayed in a monospace font.

function <code>int m2()</code> is nice

function int m2() is nice

Syntax highlighting for source code.

Computer code has colored text and more stringent formatting. For example, to define a function: int m2(), with highlights.

<syntaxhighlight lang="cpp">
#include <iostream>
int m2 (int ax, char *p_ax) {
  std::cout <<"Hello World!";
  return 0;
}</syntaxhighlight>
#include <iostream>
int m2 (int ax, char *p_ax) {
  std::cout <<"Hello World!";
  return 0;
}

Small text.

Use <small>small text</small> if needed.

A span tag can set text font-size as
being <span style="font-size:87%">87%
of prior size</span>, to match an
image caption.

Use small text if needed.

A span tag can set text font-size as being 87% of prior size, to match an image caption.

Big text.

Better not use <big>big text</big>,
unless <small> it's <big>within</big>
small</small> text.

Better not use big text, unless it's within small text.

You can include a non-breaking space (sometimes called non-printing character) where you require two words to always appear together on the same line, such as Mr. Smith or 400 km/h, using &nbsp; in place of a regular space between the two "words" that need to behave as a single word (never be separated on different lines).

Mr.&nbsp;Smith or 400&nbsp;km/h.

Mr. Smith or 400 km/h.

Extra spacing within text can best be achieved using the pad template.

Mary {{pad|4em}} had a little lamb.

Mary       had a little lamb.

Typewriter font.

(Also works beyond the end of a paragraph.)

<tt>arrow      &rarr;</tt>

<tt>''italics'', '''bold'''</tt>

<tt><nowiki>[[link]]

New paragraph </tt>started here.

arrow →

italics, bold

link

New paragraph started here.


Link to another wiki article

  • Internally, the first letter of the target page is automatically capitalized and spaces are represented as underscores (typing an underscore in the link has the same effect as typing a space, but is not recommended).
  • Thus the link hereafter is to the Web address en.wikipedia.org/wiki/Public_transport, which is the Wikipedia article with the name "Public transport". See also Canonicalization.
  • A red link is a page that doesn't exist yet; it can be created by clicking on the link.
  • A link to its own page will appear only as bold text.
What you type What it looks like

London has [[public transport]].

London has public transport.

Link to this own article: "[[Help:Wiki markup]]" will appear only as bold text.

Link to this own article: "Help:Wiki markup" will appear only as bold text.