1     //
2     // Week 2, Example of Static Members and Methods
3     //
4     // This class represents a network connection.
5     // Due to limited hardware, only 10 network
6     // connections are possible at a time. Because
7     // we don't trust programmers to check the number
8     // of connections themselves, we force them to
9     // use a static method to create a network connection.
10    // If no connections are available, the method
11    // returns 0.
12    //
13   
14    #include "w2ex4.h"
15   
16    // Global constants
17   
18    const int maxConnections = 10;
19   
20    // Static member variables for Network
21   
22    int Network::numConnections = 0;
23   
24   
25    Network *Network::makeConnection (ipaddress theAddress)
26    {
27        if (numConnections < maxConnections)
28        {
29            Network *theNetwork = new Network (theAddress);
30   
31            numConnections++;
32            return theNetwork;
33        }
34   
35        return 0;
36    }
37   
38    Network::Network (ipaddress)
39    {
40        // make a connection
41    }
42   
43    void Network::sendData (char *)
44    {
45        // send data
46    }
47   
48    char *Network::getData ()
49    {
50        // get data
51    }
52   
53   
54