(newby) missing storage class or identifier error

Discussion in 'C++' started by Sonoman, Jun 30, 2003.

  1. Sonoman

    Sonoman Guest

    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.
    Sonoman, Jun 30, 2003
    #1
    1. Advertising

  2. "Sonoman" <> wrote...
    > 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
    Victor Bazarov, Jun 30, 2003
    #2
    1. Advertising

  3. "Sonoman" <> wrote...
    > 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" <> wrote in message
    > news:...
    > > "Sonoman" <> wrote...
    > > > 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
    > >
    > >

    >
    >
    >
    Victor Bazarov, Jun 30, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page