fork download
  1. #include "nameserverinterface.h"
  2. #include "vectornameserver.h"
  3. #include <algorithm>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. namespace cpp_lab4 {
  9. void VectorNameServer::insert(const HostName &hostname, const IPAddress &ip) {
  10. store.push_back(pair<HostName, IPAddress>(hostname, ip));
  11. }
  12.  
  13. bool VectorNameServer::remove(const HostName &hostname) {
  14. vector<pair<HostName,IPAddress> >::iterator it;
  15. it = find_if(store.begin(), store.end(), bind2nd(first_equal(), hostname));
  16. if (it != store.end()) {
  17. store.erase(it);
  18. return true;
  19. }
  20. return false;
  21. }
  22.  
  23. IPAddress VectorNameServer::lookup(const HostName &hostname) const {
  24. IPAddress result = NON_EXISTING_ADDRESS;
  25.  
  26. vector<pair<HostName,IPAddress> >::iterator it;
  27. it = find_if(store.begin(), store.end(), bind2nd(first_equal(), hostname));
  28. if (it != store.end()) {
  29. result = (*it)->second;
  30. }
  31.  
  32. return result;
  33. }
  34. }
  35.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:33: error: nameserverinterface.h: No such file or directory
prog.cpp:2:30: error: vectornameserver.h: No such file or directory
prog.cpp:9: error: ‘VectorNameServer’ has not been declared
prog.cpp:9: error: expected ‘,’ or ‘...’ before ‘&’ token
prog.cpp:9: error: ISO C++ forbids declaration of ‘HostName’ with no type
prog.cpp: In function ‘void cpp_lab4::insert(int)’:
prog.cpp:10: error: ‘store’ was not declared in this scope
prog.cpp:10: error: ‘HostName’ cannot appear in a constant-expression
prog.cpp:10: error: ‘IPAddress’ was not declared in this scope
prog.cpp:10: error: template argument 1 is invalid
prog.cpp:10: error: template argument 2 is invalid
prog.cpp:10: error: ‘hostname’ was not declared in this scope
prog.cpp:10: error: ‘ip’ was not declared in this scope
prog.cpp: At global scope:
prog.cpp:13: error: ‘VectorNameServer’ has not been declared
prog.cpp:13: error: expected ‘,’ or ‘...’ before ‘&’ token
prog.cpp:13: error: ISO C++ forbids declaration of ‘HostName’ with no type
prog.cpp: In function ‘bool cpp_lab4::remove(int)’:
prog.cpp:14: error: ‘HostName’ cannot appear in a constant-expression
prog.cpp:14: error: ‘IPAddress’ was not declared in this scope
prog.cpp:14: error: template argument 1 is invalid
prog.cpp:14: error: template argument 2 is invalid
prog.cpp:14: error: template argument 1 is invalid
prog.cpp:14: error: template argument 2 is invalid
prog.cpp:14: error: expected initializer before ‘it’
prog.cpp:15: error: ‘it’ was not declared in this scope
prog.cpp:15: error: ‘store’ was not declared in this scope
prog.cpp:15: error: ‘first_equal’ was not declared in this scope
prog.cpp:15: error: ‘hostname’ was not declared in this scope
prog.cpp:15: error: ‘bind2nd’ was not declared in this scope
prog.cpp: At global scope:
prog.cpp:23: error: ‘IPAddress’ does not name a type
stdout
Standard output is empty