Week 10 - Inheritance and Enumerations, Sockets & Threads Flashcards
What is the general form for class inheritance (C++)?
class derived-class-name : access-specifier base-class-name
{ /* body of class */ }
What are the three access specifiers?
Private, public and protected
What is the difference between protected members in a class and private members in a class?
Protected members can be accessed by derived classes, while private members cannot
What is good practice in inheritance access?
Use public inheritance unless there is a good reason to do otherwise
What are the two general rules in terms of inheritance constructors and destructors?
Constructors are execute in order of derivation
Destructors are executed in reverse order of derivation
What is simple inheritance?
Where a single class inherits from a single base class
What is chain inheritance?
Where a single class inherits from a single base class, and a second single class inherits from the first class, e.g. base -> single1 -> single2
What is multiple inheritance?
Where a single class inherits from more than one base class
What are two solutions to the ambiguity created by the diamond problem?
Apply the scope resolution operator
Prevent two copies of based being included in the 3rd derivation
What is an enumeration?
A set of user-defined integer constants
How do you define and use an enumeration?
enum boolean {False, True};
enum boolean isok;
iskok = True;
By default, how do enumeration values work?
Start at 0 and increment by 1 each time
What do sockets do?
Enable two nodes on a network to talk to each other
What happens on the server side when using sockets?
Create a socket (socket)
Set socket options (setsockopt)
Bind the listener process to a specific port number (bind)
Start listening (listen)
Whenever a client requests a connection:
- Accept a connection request from a client (accept)
- Exchange data with the client (send, read)
- Close connection (close)
What happens client side when using sockets?
Create a socket (socket)
Request a connection (connect)
Exchange data with server (send, read)