/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Converter.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/30 08:45:12 by narnaud #+# #+# */ /* Updated: 2022/07/12 08:42:27 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "Converter.hpp" Converter::Converter (void) { cout << "Converter default constructor called " << endl; } Converter::Converter (string str):_input(str){ startConv(); cout << "Converter parameter constructor called" << endl; } Converter::Converter (Converter const & src) { (void)src; cout << "Converter copy constructor called" << endl; } Converter & Converter::operator= (Converter const & src) { (void)src; cout << "Converter assignment operator called" << endl; return (*this); } Converter::~Converter (void) { cout << "Converter default destructor called" << endl; } void Converter::startConv(void) { if (_input[0] == '\'' || _input[0] == '"') { _c = _input[1]; _d = static_cast(_c); } else { _d = std::strtod(_input.c_str(), 0); _c = static_cast(_d); } _i = static_cast(_d); _f = static_cast(_d); } void Converter::display(void) { cout << "Input: " << _input << endl; cout << "Char: " << _c << endl; cout << "Double: " << _d << endl; cout << "Float: " << _f << endl; cout << "Integer: " << _i << endl; }