This preview shows page 1. Sign up to view the full content.
Unformatted text preview: instance name as a prefix, followed by . as in It shows that streams are just instances of a
stream class –
stream objects. list.Initialise(); (They also look the same as references to
struct Does this form seem familiar?
Applied Programming So we can call
list.Initialise(); Applied Programming Its name is the name of the class.
And it has no type (not even void).
void But C++ helps us more than that.
W e can set up the values of any private data
automatically when the variable is declared.
automatically So, for our LinkedList class we have the
LinkedList(); A special public function is created, called
constructor in our interface. Applied Programming Its implementation would be Applied Programming For example, LinkedList::LinkedList()
Head = 0;
} void A()
} How do we call it?
We would generate a call to the constructor.
C++ automatically calls it when we declare an
View Full Document
This document was uploaded on 04/07/2014.
- Spring '14