I'm trying to learn c++ and am trying to use classes. I'm doing something wrong but can't figure this out. Here's the code:
#include <iostream>
using namespace std;
class dead
{
public:
void dieNow()
{
cout<<"You just died!"<<endl;
cin.get();
}
};
class alive
{
public:
void youLive()
{
cout<<"Whew! You barely made it!"<<endl;
cin.get();
}
};
int main()
{
int a;
cout<<"Please enter 1 or 2"<<endl;
cin.get();
cin>>a;
cin.get();
if (a == 1)
{
dead nowDead;
nowDead.dieNow();
}
if (a == 2)
{
alive youAlive;
youAlive.youLive();
}
return 0;
}
This one really baffles me because when I do enter 1, it does nothing, but when I enter 2, it gives me what I want. I don't know how to get 1 to work when I type it in.
I've also got a question about learning to program in C++. I'm trying to learn by way of gaming so I can program games as a hobby, that's why I'll post the types of code like I have above. Here's my question if anybody knows: Can one use c++ in order to create something like Halo? Or are there other tools involved in the gaming process?
Thanks!