Open alexey-malov opened 5 years ago
class CSolidBody : public CBody
{
public:
CSolidBody(const std::string& type, double density);
double GetDensity() const override;
virtual double GetVolume() const = 0;
[ ] В CSolidBody не надо повторно объявлять чисто виртуальный метод GetVolume, потому что он уже был объявлен чисто виртуальным в базовом классе
[ ] То же самое касается метода AppendProperties
double CCompound::GetDensity() const
{
return GetMass() / GetDensity();
}
double CCompound::GetVolume() const
{
double volume = 0;
for (shared_ptr<CBody> body : m_children)
{
volume += body->GetMass();
}
return volume;
}
[ ] Перебор указателей огранизовать по константной ссылке
[ ] Почему к объёму прибавляется масса?
bool CCompound::AddChildBody(shared_ptr<CBody> child)
{
/*if (make_shared<CBody>(this) == child)
{
return false;
}*/
try
{
m_children.push_back(child);
}
catch (const exception& e)
{
std::cout << e.what() << '\n';
return false;
}
return true;
}
[ ] Зачем мы здесь перехватываем исключение?
[ ] Нет защиты от добавления объекта внутрь себя самого (прямо или косвенно).
https://docs.microsoft.com/en-us/cpp/build/creating-precompiled-header-files?view=vs-2019