Example #1
0
// note: this function is not a member function!
Cents operator-(const Cents &c1, const Cents &c2)
{
	// use the Cents constructor and operator-(int, int)
	// we can access m_cents directly because this is a friend function
	return Cents(c1.m_cents + c2.m_cents);
}
Cents Cents::operator+(int nCents)
{
    return Cents(m_nCents + nCents);
}
Example #3
0
#include "cloud.hpp"
#include "level.hpp"
#include "path.hpp"
#include "message.hpp"

ammoStats::ammoStats( const char* n, AmmoType at, int c, long p, int w, char ns, char acc, AmmoEffect eff )
    : name(n), type(at), color(c), price(p), weight(w), numslugs(ns), accuracy(acc), effect(eff) {}

ammoStats AmmoStorage [] =
{

    //__       Name                 type                         price        wgt slug acc

    ammoStats("#light pistol bullet~",   bul_lpistol,  cBlue,  CentP100( 44),  1,  1,  0, ae_none ),
    ammoStats("#heavy pistol bullet~",   bul_hpistol,  cLBlue, CentP100( 44),  1,  1,  0, ae_none ),
    ammoStats("#silver bullet~",         bul_lpistol,  cWhite, Cents( 44),     1,  1,  0, ae_none ),

    ammoStats("#rifle bullet~",    bul_rifle,   cGreen, CentP100( 70),  1,  1,  0, ae_none ),

    ammoStats("#shotgun shell~",   bul_shotgun, cBrown, CentP100(112),  1,  6, -8, ae_none ),

    ammoStats("#light harpoon~", bul_harpoon, cGrey,   Cents(20),  2,  1, 0, ae_none ),

    ammoStats("#needle slug~",   bul_needle, cRed,   CentP100(140),  1,  1, +1, ae_none ),
    ammoStats("#barb slug~",     bul_needle, cLRed,  CentP100(280),  1,  1,  0, ae_none ),

    ammoStats("#grenade~",         bul_grenade, cYellow,   Dollars(2),  4,  1, -8, ae_explode ),
    ammoStats("#smoke bomb~",      bul_grenade, cLGrey,     Cents(90),  4,  1, -8, ae_smoke ),
    ammoStats("#gas grenade~",     bul_grenade, cOrange,   Cents(120),  4,  1, -8, ae_gas ),

    //  ammoStats("#heavy rivet~",     bul_rivet,   2,  1,  0, ae_none ),
// note: this function is a member function!
Cents Cents::operator-()
{
    return Cents(-m_nCents);
}
 // Allow us to convert Dollars into Cents
 operator Cents() { return Cents(m_nDollars * 100); }