C++ Lecture 6 - C Lecture 6...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
C++ Lecture 6 http://www.cs.mun.ca/~gstarkes/3710/c++/lecture6.html 1 of 4 4/13/2009 5:28 PM C++ Lecture 6 [Previous Lecture] [Lecture Index] [Next Lecture] MyPoint.h #ifndef MY_POINT_H # define MY_POINT_H # include "point.h" class MyPoint : public Point { public: double abs() { return sqrt(x * x + y * y); } }; #endif /* MY_POINT_H */ Virtual Methods allows base class methods to be `replaced' (overridden) by deri ved class (even when method is used in the base class) virtual only needed in base class (the same methods in derived class a re implicitly virtual) can't have virtual instance variables a class with a virtual method must define the method (unless. ..) Abstract Methods: Created using the syntax: virtual myMethod(. ..) = 0 ; allows base class to specify an interface without implementing it. forces derived class to implement it (unless they declare the m ethod as abstract). all abstract base classes should have a virtual destructor to allow the subclass destructor to be called Inline Functions and Methods
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/24/2009 for the course PROGRAMMIN C++ Progra taught by Professor Showman during the Spring '09 term at Zagazig University.

Page1 / 5

C++ Lecture 6 - C Lecture 6...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online