Original Post
Hey all. I started some experiments with pointers, but I just can't get this to work. The code is pretty obvious, so I didn't comment it. It doesn't seem to like my functions much. Here are the compiling errors I am getting: (39) : error C2144: syntax error : missing ')' before type 'int' (39) : error C2660: 'destroy' : function does not take 0 parameters (39) : error C2059: syntax error : ')' Error executing cl.exe. Thanks alot!
#include <iostream>
using namespace std;
class rpg
{
public:
int damage();
int destroy(int sword, int *p_sword);
};
int rpg::damage()
{
int sword = 50;
int *p_sword = &sword
cout << "In rpg::damage();...\n";
cout << "Sword Damage: " << sword << endl;
cout << "*p_sword Damage: " << *p_sword << endl;
return sword;
return *p_sword;
}
int rpg::destroy(int sword, int *p_sword)
{
cout << "\nIn rpg::destroy();...\n";
cout << "Sword Damage: " << sword << endl;
cout << "*p_sword Damage: " << *p_sword << endl;
cout << "Changing sword damage to 100...";
sword = 100;
cout << "\nSword Damage: " << sword << endl;
cout << "*p_sword Damage: " << *p_sword << endl;
return 0;
}
int main()
{
rpg stuff;
stuff.damage();
stuff.destroy(int sword, int *p_sword);
return 0;
}