I want to assign a private int to 250 and a public function to be able to call for the value of that private value. How can I do this? Here is what I have, hopefully someone can see where I am trying to go with this and help me out:
1 2 3 4 5 6 7 8 9 10 11 12 13
class bruteForce{
public:
int getHP()
{
return hp;
}
private:
int hp = 250 ;
};
EDIT: sorry I got that wrong, you can have const static ints declared, but not static ints, or ints. like Disch said above you can simply declare in constructor.
eg this will work...:
xxx.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#ifndef XXX_H_
#define XXX_H_
#include <iostream>
#include <string>
usingnamespace std;
class MyClass
{
public:
conststaticint ZSIZE=100;
int hp;
private:
conststaticint BBSIZE=666;
int ph;
};
#endif