fork download
  1. #ifndef VECTORNAMESERVER_H
  2. #define VECTORNAMESERVER_H
  3.  
  4. #include "nameserverinterface.h"
  5. #include <vector>
  6. #include <utility>
  7.  
  8. using std::vector;
  9. using std::pair;
  10.  
  11. namespace cpp_lab4 {
  12.  
  13. class VectorNameServer : public NameServerInterface
  14. {
  15. public:
  16. VectorNameServer();
  17. ~VectorNameServer();
  18.  
  19. /*
  20.   * Insert a name/address pair. Does not check if the name
  21.   * or address already exists.
  22.   */
  23. void insert(const HostName &hostname, const IPAddress &ip);
  24.  
  25. /*
  26.   * Remove the pair with the specified host name. Returns true
  27.   * if the host name existed and the pair was removed, false
  28.   * otherwise.
  29.   */
  30. bool remove(const HostName &hostname);
  31.  
  32. /*
  33.   * Find the IP address for the specified host name. Returns
  34.   * NON_EXISTING_ADDRESS if the host name wasn't in the name
  35.   * server.
  36.   */
  37. IPAddress lookup(const HostName &hostname) const;
  38.  
  39. private:
  40. vector<pair<HostName, IPAddress> > store;
  41. };
  42.  
  43. struct first_equal : binary_function<pair<HostName, IPAddress>,HostName,bool> {
  44. bool operator() (const pair<HostName, IPAddress>& x, const HostName& y) const
  45. {return x.first == y;}
  46. };
  47. }
  48.  
  49. #endif
  50.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:33: error: nameserverinterface.h: No such file or directory
prog.cpp:14: error: expected class-name before ‘{’ token
prog.cpp:23: error: expected ‘,’ or ‘...’ before ‘&’ token
prog.cpp:23: error: ISO C++ forbids declaration of ‘HostName’ with no type
prog.cpp:30: error: expected ‘,’ or ‘...’ before ‘&’ token
prog.cpp:30: error: ISO C++ forbids declaration of ‘HostName’ with no type
prog.cpp:37: error: ‘IPAddress’ does not name a type
prog.cpp:40: error: ‘HostName’ was not declared in this scope
prog.cpp:40: error: ‘IPAddress’ was not declared in this scope
prog.cpp:40: error: template argument 1 is invalid
prog.cpp:40: error: template argument 2 is invalid
prog.cpp:40: error: template argument 1 is invalid
prog.cpp:40: error: template argument 2 is invalid
prog.cpp:43: error: expected template-name before ‘<’ token
prog.cpp:43: error: expected `{' before ‘<’ token
prog.cpp:43: error: expected unqualified-id before ‘<’ token
prog.cpp:47: error: expected `}' at end of input
stdout
Standard output is empty