|
@@ -27,6 +27,51 @@ Before you get to the laboratory you should have:
|
27
|
27
|
|
28
|
28
|
---
|
29
|
29
|
|
|
30
|
+##Classes and Objects in C++
|
|
31
|
+
|
|
32
|
+An *object* is an entity that contains data and procedures to manipulate them. Similar to how each variable has a *type* of data associated to it, each object has a *class* associated to it, which describes the properties of the the objects: its data (*attributes*), and the procedures that can be used to manipulate its data (*methods*).
|
|
33
|
+
|
|
34
|
+It is not necessary to know all of the details about the methods of the object to define and use an object, but you must know how to create it and how to interact with it. The necessary information is available in the class' documentation. Before creating objects of any class, we should familiarize ourselves with its documentation. The documentation indicates, among other things, what entity is trying to be represented in the class, and its interface or methods available to manipulate the objects of the class.
|
|
35
|
+
|
|
36
|
+Take a look at the documentation of the `Bird` class which can be found in [this link.](http://ada.uprrp.edu/~ranazario/bird-html/class_bird.html).
|
|
37
|
+
|
|
38
|
+###Classes
|
|
39
|
+
|
|
40
|
+A class is a description of the data and processes of an object. The class’ declaration establishes the attributes that each of the objects of the class will have, and the methods that it can invoke.
|
|
41
|
+
|
|
42
|
+If it isn't specified otherwise, the attributes and methods defined in a class will be private. This means that the variables can only be accessed and changed by the methods of the class (*constructors*, *setters*, and *getters*, among others).
|
|
43
|
+
|
|
44
|
+The following is the skeleton of the declaration of a class:
|
|
45
|
+
|
|
46
|
+---
|
|
47
|
+
|
|
48
|
+```
|
|
49
|
+ class ClassName
|
|
50
|
+ {
|
|
51
|
+ // Declarations
|
|
52
|
+
|
|
53
|
+ private:
|
|
54
|
+ // Declaration of variables or attributes
|
|
55
|
+ // and prototype member functions
|
|
56
|
+ // that are private for this class
|
|
57
|
+
|
|
58
|
+ type privateVar
|
|
59
|
+ type nameOfPrivateMemFunc(type of the parameters);
|
|
60
|
+
|
|
61
|
+ public:
|
|
62
|
+ // Declarations of attributes
|
|
63
|
+ // and prototypes of method functions
|
|
64
|
+ // that are public for the entire program
|
|
65
|
+
|
|
66
|
+ type publicVar;
|
|
67
|
+ type nameOfPublicMemFunc(type of the parameters);
|
|
68
|
+ };
|
|
69
|
+```
|
|
70
|
+
|
|
71
|
+---
|
|
72
|
+
|
|
73
|
+---
|
|
74
|
+
|
30
|
75
|
## Communication among computers
|
31
|
76
|
|
32
|
77
|
Computers communicate with each other through the Internet Protocol (IP). When a computer sends information to another computer, the information is sent via *Internet packets* that contain the *source address*, which is the Internet address of the computer sending the information, and the *destination address*, which is the Internet address of the computer that receives the message. The Internet addresses are used to guide the information from one computer to another, but once the arrives to its destination, who is supposed to receive the information? Which application must receive the information?
|