/*
* File: Rifle.hpp
* Author: Cameron
*
* Created on 1 June 2012, 3:59 PM
*/
#include <iostream>
usingnamespace std;
class Rifle
{
public:
Rifle(int initialRAmmo);
~Rifle();
int getRAmmo() const { return RAmmo; }
void setRAmmo(int RAmmo);
void shootRifle()
{
if (RAmmo > 1)
{
setRAmmo(RAmmo - 1);
cout << "Shooting the Rifle...\n";
}
else
{
cout << "Out of ammo you need to reload.\n";
}
}
void reloadRifle()
{
if (RAmmo != 6)
{
setRAmmo(RAmmo = 6);
cout << "Reloading the Rifle...\n";
}
else
{
cout << "You don't need to reload, you have a full clip\n";
}
}
private:
int RAmmo;
};
1>c:\users\cameron\documents\visual studio 2010\projects\gunzerama\gunzerama\main.cpp(59): error C2228: left of '.shootRifle' must have class/struct/union
1>c:\users\cameron\documents\visual studio 2010\projects\gunzerama\gunzerama\main.cpp(63): error C2228: left of '.reloadRifle' must have class/struct/union
1>c:\users\cameron\documents\visual studio 2010\projects\gunzerama\gunzerama\main.cpp(77): error C2228: left of '.shootShotgun' must have class/struct/union
1>c:\users\cameron\documents\visual studio 2010\projects\gunzerama\gunzerama\main.cpp(81): error C2228: left of '.reloadShotgun' must have class/struct/union
int main()
{
int RifleOrShotgun, decision;
// Rifle Rifle1(); // *** this declares a function
// Shotgun Shotgun1(); // *** and this too
Rifle Rifle1 ; // this defines an object
Shotgun Shotgun1 ;