Skip to content

Instantly share code, notes, and snippets.

@MasazI
Created May 25, 2015 05:52
Show Gist options
  • Select an option

  • Save MasazI/811edad424ec5ed08ad1 to your computer and use it in GitHub Desktop.

Select an option

Save MasazI/811edad424ec5ed08ad1 to your computer and use it in GitHub Desktop.
chartraits.cpp
//
// 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