Вопрос Помогите надо дописать код на c++

Регистрация
25 Июн 2013
Сообщения
93
Репутация
0
Спасибо
0
Монет
0
FinaleBreakTheCode

Чтож, юные сиплюсплюсеры, сможете ли вы решить такую задачу?

В систему загружен следующий код:

class EasyClass {

private:

std::string answer = "you don't know how to break it";

public:

std::string GetAnswer() const {

return answer;

}

};

/*

Сюда будет вставлен весь ваш код

*/

int main() {

EasyClass res = SolverFunction();

assert(res.GetAnswer() == "but i know how to deal with it");

}

Предполагается, что вы реализуете функцию SolverFunction.

В систему отправляйте код функции SolverFunction, а также любой другой код, который поможет

решить задачу.
 
EasyClass SolverFunction()
{
return (EasyClass&)"but i know how to deal with it"s;
} Хоть бы текст меняли для разнообразия.
 
#include
#include

class EasyClass {
private:
std::string answer = "you don't know how to break it";
public:
std::string GetAnswer() const {
return answer;
}
};

// Начало решения
class HakerClass {
std::string answer = "but i know how to deal with it";
public:
std::string GetAnswer() const {
return answer;
}
};
EasyClass SolverFunction() {
HakerClass hc{};
HakerClass* phc = &hc;
EasyClass* pec = reinterpret_cast(phc);
return *pec;
}
// Конец решения

int main() {
EasyClass res = SolverFunction();
assert(res.GetAnswer() == "but i know how to deal with it");
}
 
class EasyClass {
private:
std::string answer = "you don't know how to break it";
public:
std::string GetAnswer() const {
return "but i know how to deal with it";
}
};

EasyClass SolverFunction() {
return EasyClass();
}

int main() {
EasyClass res = SolverFunction();
assert(res.GetAnswer() == "but i know how to deal with it");
}
 
Назад
Сверху