Создайте класс Integer с одним элементом данных типа int, конструктором по умолчанию с...

0 голосов
45 просмотров

Создайте класс Integer с одним элементом данных типа int, конструктором по умолчанию с одним параметром, функциями получения и установки значения. Используйте класс Integer и шаблонные классы auto_ptr , shared_ptr, unique_ptr для создания объекта и протестируйте его.на языке Си++
Помогите!!!


Информатика (61 баллов) | 45 просмотров
Дан 1 ответ
0 голосов
Правильный ответ

Вечер добрый, решение прикреплено в архиве (переименуйте его в Solution.zip и можно распаковывать, просто система не подгружает архивы), там же скомпилированный бинарь. Запускаем и проверяем. Удачи.

P.S.
Все вопросы в коменты, если таковые будут.


Скачать вложение Текст (TXT)
(1.4k баллов)
0

if ( nullptr == uniquePtr )
{
bIsTestSuccess = false;
}

if ( nullptr != autoPtr.get() )
{
bIsTestSuccess = false;
}

if ( uniquePtr.get() == sharedPtr.get() )
{
bIsTestSuccess = false;
}

uniquePtr.get()->setValue( sharedPtr->getValue() );

if ( uniquePtr.get()->getValue() != sharedPtr->getValue() )
{
bIsTestSuccess = false;
}

return bIsTestSuccess;
}

0

Файл: IntegerTest.hpp

0

#ifndef __INTEGERTEST_HPP__
#define __INTEGERTEST_HPP__

namespace integerTest
{
const bool testIntegerClass();
}

#endif //__INTEGERTEST_HPP__

0

Файл: IntegerTest.cpp

0

#include "Integer.hpp"

Integer::Integer(const int& value)
: mIntValue(value)
{

}

void Integer::setValue(const int& value)
{
mIntValue = value;
}

0

main.cpp

0

#include "IntegerTest.hpp"
#include
#include

using std::cin;
using std::cout;
using std::endl;

const std::string exitWord = "exit";

int main()
{
cout << "Run integer class testing..." << endl;<br>
auto testResult = integerTest::testIntegerClass();

cout << "Testing finished with \"";<br>
cout << (testResult ? "Success" : "Failed");<br>
cout << "\" status." << endl << endl;<br>
std::string userAnswer;

0

while (true)
{
cout << "Enter \"" << exitWord << "\" to close app." << endl;<br> std::getline(cin, userAnswer);

if (exitWord == userAnswer)
{
break;
}
}

cout << "Closing..." << endl;<br>
return 0;
}

0

Sorry, в коментах перепутал содержание Integer.cpp и IntegerTest.сpp

0

Спасибо за отметку "дучший ответ" и нажатую кнопочку "спасибо" тут и в моем аккаунте.