Not really for the beginners. If you had experience working with C++ in the past, then taking a look at this short-note will help to recover your knowledge in C++.
Multiple inheritance means that one subclass can have more than one superclass. This enables the subclass to inherit properties of more than one superclass and to “merge” their properties.
char *strp; /* strp is `pointer to char’ */
*strp = ‘a’; /* A single character */
A pointer to characters can be used to point to a sequence of characters
Class Structure:
class Foo {
// private as default …
public:
// what follows is public until …
private:
// … here, where we switch back to private …
public:
// … and back to public.
};
Struct:
class Struct {
public: // Structure elements are public by default
// elements, methods
};
Method definition – outside of the class
void Point::setX(const int val) {
_x = val;
}
void Point::setY(const int val) {
_y = val;
}
Access a method:
apoint.setX(1); // Initialization
Inheritance:
class Point3D : public Point {}
C++ has two types of inheritance: public and private. By default, classes are privately derived from each other
You can inherit as private, protected, public. Private members always come as private in the subclass. Public members of the super class come to the subclass according/(as) to the inheritance type
Multiple Inheritance:
class DrawableString : public Point, public DrawableObject {}
Virtual Function in C++
You can use the keyword ‘virtual’ before a function declaration to make the function virtual. Subclasses to these class can define the function as they want. It still remains virtual in the subclasses.
http://www.codersource.net/published/view/325/virtual_functions_in.aspx
— will update and add later
Reference: http://gd.tuwien.ac.at/languages/c/c++oop-pmueller/tutorial.html
From: http://sitestree.com/?p=5240
Categories:77
Tags:
Post Data:2006-08-17 00:14:30
Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada