arithop.cpp

来自「2009 ROBOCUP 仿真2DSERVER 源码」· C++ 代码 · 共 83 行

CPP
83
字号
// -*-c++-*-/***************************************************************************                                 arithop.cc                  Flyweight classes representing comparison operators                             -------------------    begin                : 22-MAR-2002    copyright            : (C) 2002 by The RoboCup Soccer Server                           Maintainance Group.    email                : sserver-admin@lists.sourceforge.net***************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU LGPL as published by the Free Software  * *   Foundation; either version 2 of the License, or (at your option) any  * *   later version.                                                        * *                                                                         * ***************************************************************************/#include "arithop.h"namespace rcss {namespace util {const char * ArithOp::STRINGS[] = { "+", "-", "*", "/" };ArithOp::ArithOp( const arith_t & arith )    : M_arith( arith ){}const char *ArithOp::getStr() const{    return STRINGS[ M_arith ];}const ArithOp &ArithOp::instance( const arith_t & arith ){    // The entire collection of ArithOps is created on the first    // call to ArithOp::instance.  Because the array is a static    // varaible in this function, we can legally return references    // to its elements.  One of the advatages of doing this is    // that the ArithOps will be destroyed automatically.    static ArithOp instances[] = { ArithOp( PLUS ),                                   ArithOp( MINUS ),                                   ArithOp( MULT ),                                   ArithOp( DIV ) };    return instances[ arith ];}const ArithOp &ArithOp::plus(){    return instance( PLUS );}const ArithOp &ArithOp::minus(){    return instance( MINUS );}const ArithOp &ArithOp::mult(){    return instance( MULT );}const ArithOp &ArithOp::div(){    return instance( DIV );}}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?