Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
АФТИ ООП 2013-2014. Лекция I/06
Search
Oleg Dashevskii
October 14, 2013
Education
0
140
АФТИ ООП 2013-2014. Лекция I/06
Oleg Dashevskii
October 14, 2013
Tweet
Share
More Decks by Oleg Dashevskii
See All by Oleg Dashevskii
Лекция № 13. Практическое руководство по разработке
be9
0
1.6k
Лекция № 12. Ещё о проектировании
be9
0
1.5k
Лекция № 11. Принцип отделения интерфейса. «Малое ООП»
be9
0
1.5k
Лекция № 10. Графическая нотация. Принципы LSP и DIP
be9
0
1.6k
Лекция № 9. Отношения между классами. Принцип открытия-закрытия
be9
0
1.5k
Лекция № 8. Хорошие и плохие ОО-программы
be9
0
1.5k
Лекция № 7. algorithm. Исключения
be9
1
1.5k
Лекция № 6. Стандартная библиотека C++. Часть 2
be9
0
1.6k
Лекция № 5. Стандартная библиотека C++. Часть 1
be9
0
1.6k
Other Decks in Education
See All in Education
Web Architectures - Lecture 2 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
万博マニアックマップを支えるオープンデータとその裏側
barsaka2
0
890
Alumnote inc. Company Deck
yukinumata
0
3.5k
the difficulty into words
ukky86
0
140
Transición del Management al Neuromanagement
jvpcubias
0
240
Test-NUTMEG紹介スライド
mugiiicha
0
230
1014
cbtlibrary
0
260
みんなのコードD&I推進レポート2025 テクノロジー分野のジェンダーギャップとその取り組みについて
codeforeveryone
0
280
20250830_MIEE祭_会社員視点での学びのヒント
ponponmikankan
1
170
Introduction - Lecture 1 - Web Technologies (1019888BNR)
signer
PRO
0
5.6k
EVOLUCIÓN DE LAS NEUROCIENCIAS EN LOS CONTEXTOS ORGANIZACIONALES
jvpcubias
0
180
2025年度春学期 統計学 第13回 不確かな測定の不確かさを測る ー 不偏分散とt分布 (2025. 7. 3)
akiraasano
PRO
0
140
Featured
See All Featured
Visualization
eitanlees
149
16k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Into the Great Unknown - MozCon
thekraken
40
2.1k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Writing Fast Ruby
sferik
629
62k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
9
590
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Transcript
ОБЪЕКТНО- ОРИЕНТИРОВАННОЕ ПРОГРАММИРОВАНИЕ Лекция № 6 14.10.2013 г.
В ПРОШЛОЙ СЕРИИ • Single responsibility principle (SRP). • Наследование,
агрегация, композиция, ассоциация. • Задача 1. Применение ООП к stdio.h. • Задача 2. «Малое ООП». Задача линейной аппроксимации множества точек.
ПОТОКИ В C++ ios_base ios istream ostream iostream istringstream ifstream
filebuf
ПОТОКИ В QT QObject QIODevice QFile QTextStream QBuffer QProcess QAbstract
Socket и др.
class LinearRegression { public: LinearRegression(const QPointF *_points, int _size); LinearRegression(const
QVector<QPointF> &_points); // y=Ax+B double a(); double b(); QPointF point(double x) { return QPointF(x, a()*x+b()); } double mse(); double std(); protected: void calculate(); /****/ const QPointF *points; int size; bool ready; double _a, _b; };
ЗАДАЧА 2’ Проектирование класса для линейной экспоненциальной аппроксимации набора точек
class BaseRegression { public: BaseRegression(const QPointF *_points, int _size); BaseRegression(const
QVector<QPointF> &_points); virtual double y(double x)=0; QPointF point(double x) { return QPointF(x, y(x)); } double mse(); double std(); protected: /****/ const QPointF *points; int size; };
class ExponentialRegression : public BaseRegression { public: ExponentialRegression(const QVector<QPointF> &points);
// y=A*exp(B*x) double a(); double b(); double y(double x) { return a()*exp(b()*x); } protected: void calculate(); /****/ bool ready; double _a, _b; };
void ExponentialRegression::calculate() { QVector<QPointF> logpoints(size); for (int i = 0;
i < size; ++i) logpoints[i] = QPointF(points[i].x(), log(fabs(points[i].y()))); LinearRegression lr(logpoints); _b = lr.a(); _a = exp(lr.b()); if (size > 0 && points[0].y() < 0) _a *= -1; ready = true; }
void ExponentialRegression::calculate() { QVector<QPointF> logpoints(size); for (int i = 0;
i < size; ++i) logpoints[i] = QPointF(points[i].x(), log(fabs(points[i].y()))); LinearRegression lr(logpoints); _b = lr.a(); _a = exp(lr.b()); if (size > 0 && points[0].y() < 0) _a *= -1; ready = true; } Композиция
ЗАДАЧА 3 ОО-дизайн для задачи сортировки
КОНЕЦ ШЕСТОЙ ЛЕКЦИИ