Hi Can someone please help me figure out what I am doing wrong here? I am trying to write the code for a plasma pistol but I have an error that reads
Error 1 error C2228: left of '.pressTrigger' must have class/struct/union
I know it is because oldPistol is not a class or struct but how do I fix this without screwing up my whole program? Here is my code that has the problem:
Any help will be greatly appreciated.
Error 1 error C2228: left of '.pressTrigger' must have class/struct/union
I know it is because oldPistol is not a class or struct but how do I fix this without screwing up my whole program? Here is my code that has the problem:
Code:
Code:
#include <iostream>
using namespace std;
class plasmaPistolClass
{
private:
int ammo;
int rateOfFire;
int destructivePower;
public:
bool safetyOn;
int maxAmmo;
void pressTrigger(void);
void load(int nmbrOfBolts);
void setDestructivePower(int powerSetting);
int showDestructivePower(void);
void setRateOfFire(int boltsPerTriggerPress);
int showRateOfFire(void);
int ammoRemaining(void);
plasmaPistolClass();
plasmaPistolClass(int,int);
};
int main()
{
plasmaPistolClass oldPistol();
plasmaPistolClass newPistol(7,75);
cout << "Firing Old pistol" << endl;
oldPistol.pressTrigger(); //ehis is where the error shows up at
system("pause");
return 0;
}
Comment