Created
May 25, 2015 05:52
-
-
Save MasazI/811edad424ec5ed08ad1 to your computer and use it in GitHub Desktop.
chartraits.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // chartraits.cpp | |
| // CplusplusPractice | |
| // | |
| // Created by masai on 2015/05/25. | |
| // Copyright (c) 2015年 masai. All rights reserved. | |
| // | |
| #include <iostream> | |
| using namespace std; | |
| struct result{ | |
| result(int num_success, int num_total){ | |
| num_success_ = num_success; | |
| num_total_ = num_total; | |
| } | |
| double accuracy() const{ | |
| return (num_success_ * 100.0 / num_total_); | |
| } | |
| template<typename Char, typename CharTraits> | |
| void print_summary(std::basic_ostream<Char, CharTraits>& os) const{ | |
| os << "accuracy: " << accuracy() << "% (" << num_success_ << "/" << num_total_ << ")" <<endl; | |
| } | |
| int num_success_; | |
| int num_total_; | |
| }; | |
| int main(int argc, char* argv[]){ | |
| result r(93, 100); | |
| r.print_summary(std::cout); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment