Hi, these classes for making a MuD are driving me crazy!!!
heres my starting code, haven't had more than 15 minutes to work out some basic stuff, just trying to start small, get it to compile, then add stuff...
#include<iostream>
#include<cstdio>
#include<windows.h>
#include<fstream>
#include<cstdlib>
#include<ctime>
using namespace std;
int a;
int main()
{
//Just an include for the naming, to save some space.
#include <naming.h>
//Starts player class.
class Player {
public:
int health;
int strength;
int attack;
int defence;
void move();
void attackit();
void getit(int x);
void lookit();
/*Player Constructor, USE ~ Player noob(15, 10, 20, 20);
first integer is health, second is strength,
third is attack, and fourth is defence. Use it to create a player object.
*/
Player(int h, int s, int a, int d) {
health = h;
strength = s;
attack = a;
defence = d;
}
class Armor {
int defbonus;
string description;
string name;
//Armor constructor, use to create a armor object.
Armor(int a, string b, string c) {
defbonus=a;
description=b;
name=c;
}
};
//Weapon class
class Weapon {
int attbonus;
string description;
string name;
//Weapon object construction.
Weapon(int a, string b, string c) {
attbonus=a;
description=b;
name=c;
}
};
};
Player noob(71, 72, 71, 59);
cout<<"attack\n";
cout<<noob.attack;
cout<<"\n";
cout<<"str\n";
cout<<noob.strength;
cout<<"\n";
cout<<"def\n";
cout<<noob.defence;
cout<<"\n";
cout<<"hp\n";
cout<<noob.health;
cout<<"\n";
cin>>a;
}
Here is what I am confused about!!!!
How do I make a weapon object within the player object?
I would think It would be like this, but it wont compile..
Player noob.Weapon noobsword;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Any help??? I have heard something about pointers while searching google but i'm pretty sure there is a way to do this without them, I just don't know the correct syntax. I possible, could anyone give me the corect syntax?????
And if I have to use "Pointers", then could someone show me how to use them, or point me to a good, well explained place that can?