#include #include #include class sumNumber { private: int m_sum; std::string m_iData; public: sumNumber() : m_sum(0), m_iData("") {}; void read(); void sum(); void show(); }; void sumNumber::read() { std::cin >> m_iData; } void sumNumber::sum() { for (int i = 0; i < m_iData.size(); ++i) { if (!std::isdigit(m_iData[i])) { continue; } m_sum += (m_iData[i] - 0x30); } } void sumNumber::show() { std::cout << m_sum << std::endl; } int main() { sumNumber obj; obj.read(); obj.sum(); obj.show(); }