Vla_DOS

18_29v

Feb 22nd, 2023
946
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Note {
  6.     string format;
  7.     int pages;
  8. public:
  9.     Note(string format = "", int pages = 0) {
  10.         this->format = format;
  11.         this->pages = pages;
  12.     }
  13.     string GetFormat() {
  14.         return format;
  15.     }
  16.     ~Note() {}
  17.  
  18.     void print() {
  19.         cout << "Format: " << format << endl;
  20.         cout << "Pages: " << pages << endl;
  21.     }
  22. };
  23.  
  24. void printLineNotes(Note arr[], int size) {
  25.     cout << "Line notes: " << endl;
  26.     for (int i = 0; i < size; i++) {
  27.         if (arr[i].GetFormat() == "line") {
  28.             arr[i].print();
  29.         }
  30.     }
  31. }
  32.  
  33. int main() {
  34.     const int size = 3;
  35.     Note notes[size] = { Note("line", 100),
  36.                         Note("cell", 50),
  37.                         Note("line", 200) };
  38.     printLineNotes(notes, size);
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment