Skip to content

Conversation

@LexichWhyNot
Copy link

No description provided.

@LexichWhyNot LexichWhyNot changed the title кмбо 03 21 поляковаа новая ветвь КМБО 03 21 Поляков А.А. новая ветвь Jun 6, 2022
return false;
else {
pole->connectedObjectPole = "";
pole->connectedObject = nullptr;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не отключаете другой объект от этого.

Lamp lamp_test;
Switch switch_test;
generator_test.connect("A1", lamp_test, "A1");
lamp_test.connect("A2", switch_test, "A1");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Общее замечание, не касаемо программирования: выключатель ставится до нагрузки (говоря умными словами, коммутирует фазу/плюс, для переменного/постоянного тока, соответственно), чтобы отключать её от потенциала на линии.

private:
bool CanMoveFreely;
public:
Animal() { CanMoveFreely = 0; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не выполнен пункт задания с использованием protected.

virtual string about() const { return (stringstream() << "CanMoveFreely =" << CanMoveFreely).str(); }

};

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нет перегрузки операции вывода в поток для Animal.

/// </summary>
/// <param name="b">Изучаемый объект</param>
void printInternals(const B& b) {
void printInternals(B& b) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если потребовалось отказаться от const для метода, не подразумевающей изменение состояния объекта, то что-то явно сделано не так.

}

float A::getData(int idx) const {
return ((float*)(this + 2))[idx];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему (this + 2)?

#include <ostream>
#include <string>

using namespace std;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Использовать using namespace в заголовочных файлах нежелательно.

public:
std::string getBString() const;
A();
virtual string getBString() const;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Идея как раз в том, чтобы продемонстрировать обход штатных (ограничений) средств языка для доступа к полям дочерних классов. В том числе и механизма виртуальных функций.

vectors/vector.h Outdated
std::ostream& operator <<(std::ostream& os, const vector3d& v);
#include <iostream>
using namespace std;
int main() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему main() в заголовочном файле?

{
if ((data[0] == 0) && (data[1] == 0) && (data[2] == 0))
{
return vector3d(data[0] = 1, data[1] = 1, data[2] = 1);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В корне неверно здесь и парой строчек ниже.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants