Staredit Network

Staredit Network -> Computers and Technical -> Global Classes Dev-C++
Report, edit, etc...Posted by Slyence on 2005-09-18 at 08:59:30
I've put all my classes above main.
CODE
...

class weapon
{
   public:
     char name[100];

     int patk;
     int pacc;
     int matk;

     bool use[numType];
};

int main()
{
...

Like that. Now I want to read in a variable from a file that contains a variable called numWeapons. After that I want to declare "example" as type class.

To declare this, I would use something like the following:
CODE
weapon example[numWeapons];

The problem is, I need example to be global.

Since I've read in a variable, I can't declare example outside of any functions can I?
Report, edit, etc...Posted by Staredit.Net Essence on 2005-09-19 at 00:34:41
Why aren't you using std::string and std::vector?
Report, edit, etc...Posted by Buletbutter on 2005-09-19 at 17:29:25
I am not sure what you are trying to do but like Rivalry says use string instead of char. An array of chars is the c way of making strings. Its more efficient to use string. Be sure to include using namespace std so you don't have to type std::whatever before everything.
Report, edit, etc...Posted by Slyence on 2005-09-19 at 21:54:43
Okay I got it.

Why the hell would they call it STD...
Next Page (1)