14.12.19 - → View class Board public int winLength int...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
.h .cpp class Config { Config c; private: static Config c; // нет рекурсии т.к., переменная статик, т.е. только одна в public: // глобльной памяти Config() {} }; a. h .cpp c.cpp inline void f() { #include “a.h” void f(); int main() { void h() { } f(); f(); g(); } static void g() { } } тема: MV (model view) MVC (model view controller) A ← B – в классе B есть ссылка на A, т.е. #include “A.h” class B { A a0; A *a1; A &a2; s... }; Проблема: если перенести в другую программу только класс B (без A) , то не скомпилируется. Если зависимости A↔ B (двусторонняя), то ни один класс нельзя перенести отдельно. Следует избегать подобных зависимостей. В подобных ситуациях не работает shared pointer main() { shared_ptr_A a(new B); shared_ptr_B b(new A) a.connect(&b); b.connect(&a); }
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
user 1 server user2 View ← Controller → Model ← Controller
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: → View class Board { public: int winLength; int** board; int size; public: Board(int sz); bool move(int x, int y, bool isCross); int isWin(); int getCell(int x, int y); }; class View { private: Board* b; public: void show(); void startGame() { while(!b.isWin()) { //считать ход игрока 1 → x.y move(x, y, true); show(); //считать ход игрока 2 → x.y } } }; int main() { Board b; view v(&b); v.startGame(); } Перечисление(enumeration): enum {X_WIN = 1, O_WIN, NONE, DRAW} a; //либо всем. первому / никому a = DRAW; a = 1; //ошибка int b = DRAW; //корректно C-аналог – небезопасно, т.к. не выполняется никаких проверок препоцессор меняет код, не просматривая её. #define X_WIN 1\ тема: область видимости имён one Deinition rule. Пространство имён – namespace namespace Stack { ... }...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern