This file contains 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); | |
} |
0 件のコメント:
コメントを投稿