shushus

Спринт 1. Зачем нужны классы.

Dec 3rd, 2022
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. class SearchServer {
  9.     // Содержимое раздела public: доступно для вызова из кода вне класса
  10. public:
  11.     int GetStopWordsSize() const {
  12.         return stop_words_.size();
  13.     }
  14.  
  15.     // Содержимое раздела private: доступно только внутри методов самого класса
  16. private:
  17.     struct DocumentContent {
  18.         int id = 0;
  19.         vector<string> words;
  20.     };
  21.  
  22.     DocumentContent documents_;
  23.     set<string> stop_words_;
  24. };
  25.  
  26. int GetStopWordsSize(const SearchServer& server) {
  27.     // Верните количество стоп-слов у server
  28.     return server.GetStopWordsSize();
  29. }
  30.  
  31. int main() {
  32.     // 1. Создайте переменную server типа SearchServer
  33.     SearchServer server;
  34.     // 2. Вызовите функцию GetStopWordsSize, передав ей объект server
  35.    
  36.     // 3. Выведите результат, возвращёный функцией GetStopWordsSize в cout
  37.     cout<< GetStopWordsSize(server)<<endl;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment