(newby) missing storage class or identifier error

S

Sonoman

Hi all:
I am getting a "missing storage class or idetifier" error and I do not
understand what it means, therefore and I cannot figure it out. I am just
starting a new project and I cannot get past this (may be very simple)
error. My code is as follows:

/////////////////////////array.h
#ifndef array_h
#define array_h

const int MAX = 10;

class array
{
public:
array();
~array();
run();


private:
string playerNames[MAX];
int curTurn;
int numPlayers;
int i;
};

#endif

/////////////////////////array.cpp
#include "array.h"
#include <iostream>
#include <string>

using namespace std;

array::array()
{
for (i = 0; i < MAX; i++)
{
playerNames = " ";
}
curTurn = 0;
numPlayers = 0;
}

array::run()
{
for (i = 0; i < MAX; i++)
{
playerNames = " ";
}
curTurn = 0;
numPlayers = 0;
}

/////////////////////////main.cpp
#include "array.h"
//#include <string>

int main()
{
array a;
a.run();

return 0;
}

/////////////////////////end of code

Thanks in advance.
 
V

Victor Bazarov

Sonoman said:
Hi all:
I am getting a "missing storage class or idetifier" error and I do not
understand what it means, therefore and I cannot figure it out. I am just
starting a new project and I cannot get past this (may be very simple)
error. My code is as follows:

What does your compiler documentation say about that error?
What line of code does the compiler complain about?

/////////////////////////array.h
#ifndef array_h
#define array_h

const int MAX = 10;

class array
{
public:
array();
~array();
run();

A function declaration needs a return value type. Did you
mean to write

void run();

?
private:
string playerNames[MAX];

'string' is most likely undefined here. Did you forget to
include the right header?
int curTurn;
int numPlayers;
int i;
};

#endif

/////////////////////////array.cpp
#include "array.h"
#include <iostream>
#include <string>

using namespace std;

array::array()
{
for (i = 0; i < MAX; i++)
{
playerNames = " ";
}
curTurn = 0;
numPlayers = 0;
}

array::run()


Again, a function definition should begin with the return
value type. Did you mean to write

void array::run()

???
{
for (i = 0; i < MAX; i++)
{
playerNames = " ";
}
curTurn = 0;
numPlayers = 0;
}

/////////////////////////main.cpp
#include "array.h"
//#include <string>

int main()
{
array a;
a.run();

return 0;
}

/////////////////////////end of code

Thanks in advance.


HTH

Victor
 
V

Victor Bazarov

Sonoman said:
Fixed the "void" error, but the compiler still does not like the *****
marked line.

(a) Your code below does not have "the ***** marked line".
(b) Include <string> into that header and make sure you declare
'playerNames' as
std::string playerNames[MAX];

Victor Bazarov said:
Sonoman said:
Hi all:
I am getting a "missing storage class or idetifier" error and I do not
understand what it means, therefore and I cannot figure it out. I am just
starting a new project and I cannot get past this (may be very simple)
error. My code is as follows:

What does your compiler documentation say about that error?
What line of code does the compiler complain about?

/////////////////////////array.h
#ifndef array_h
#define array_h

const int MAX = 10;

class array
{
public:
array();
~array();
run();

A function declaration needs a return value type. Did you
mean to write

void run();

?
private:
string playerNames[MAX];

'string' is most likely undefined here. Did you forget to
include the right header?
int curTurn;
int numPlayers;
int i;
};

#endif

/////////////////////////array.cpp
#include "array.h"
#include <iostream>
#include <string>

using namespace std;

array::array()
{
for (i = 0; i < MAX; i++)
{
playerNames = " ";
}
curTurn = 0;
numPlayers = 0;
}

array::run()


Again, a function definition should begin with the return
value type. Did you mean to write

void array::run()

???
{
for (i = 0; i < MAX; i++)
{
playerNames = " ";
}
curTurn = 0;
numPlayers = 0;
}

/////////////////////////main.cpp
#include "array.h"
//#include <string>

int main()
{
array a;
a.run();

return 0;
}

/////////////////////////end of code

Thanks in advance.


HTH

Victor

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top