-
A data type is called an ADT if a programmer who uses the data type does not have access to the details of how the values and operations are implemented.
-
ADT Components:
1. Variables are private.
2. Functions are public.
3. Helping functions are private.
-
Inheritance is the process by which a new class is created from another class, but the new class has additional member variables and/or functions.
-
A Class is a definition of a new data type. The definition inlcudes member variables and functions.
-
An Object is a variable declared using a class as the data type.
-
Inheritance is the process by which a new class is created from another class, but the new class has additional member variables and/or functions.
-
Inheritance allows us to reuse C++ code that has already been developed and tested.
-
Inheritance Terminology:
Base Class --------------> Derived Class
Parent Class --------------> Child Class
Super Class --------------> Sub Class
-
A Derived Class would be able to do everything the base class can do, plus it would add some attributes or operations to increase its functionality.
-
Why do we need to know what each stream class inherits?
So we can understand the possibilities and limitations when writing functions that use classes as parameters.
-
A data type consists of a collections of values together with a set of basic operations defined on those values.
-
The interface of an ADT tells you how to use the ADT in your program.
-
The implementation of the ADT tells how the interface is realized as C++ code. The implementation of the ADT consists of the private member of the class and the definitions of both the public and private member functions.
-
The most obvious benefit you derive from making your classes ADTs is that you can change the implementation without needing to change the other parts of your program.
-
A Derived Class is defined by adding a colon followed by the keyword public and the name of the parent or base class:
class ChildClass : public ParentClass
{
public:
private:
};
-
A function can be overloaded to take arguments of different types. An operator is really a function, so an operator can be overloaded. The way you overload an operator, such as +, is basically the same as the way you overload a function name.
friend ClassName operator +(const ClassName& objectName1, const ClassName& objectName2);
-
When you add an & to the name of a returned type, you are saying that the operator (or function) returns a reference, which means that you are returning the object itself, as opposed to the value of the object.
|
|