(newby) missing storage class or identifier error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sonoman

    (newby) missing storage class or identifier error

    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[i] = " ";
    }
    curTurn = 0;
    numPlayers = 0;
    }

    array::run()
    {
    for (i = 0; i < MAX; i++)
    {
    playerNames[i] = " ";
    }
    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.



  • Victor Bazarov

    #2
    Re: (newby) missing storage class or identifier error

    "Sonoman" <fcarpio@REMOVE cse.fau.edu> wrote...[color=blue]
    > 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:[/color]

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

    [color=blue]
    > /////////////////////////array.h
    > #ifndef array_h
    > #define array_h
    >
    > const int MAX = 10;
    >
    > class array
    > {
    > public:
    > array();
    > ~array();
    > run();[/color]

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

    void run();

    ?
    [color=blue]
    >
    >
    > private:
    > string playerNames[MAX];[/color]

    'string' is most likely undefined here. Did you forget to
    include the right header?
    [color=blue]
    > 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[i] = " ";
    > }
    > curTurn = 0;
    > numPlayers = 0;
    > }
    >
    > array::run()[/color]

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

    void array::run()

    ???
    [color=blue]
    > {
    > for (i = 0; i < MAX; i++)
    > {
    > playerNames[i] = " ";
    > }
    > 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.[/color]

    HTH

    Victor


    Comment

    • Victor Bazarov

      #3
      Re: (newby) missing storage class or identifier error

      "Sonoman" <fcarpio@REMOVE cse.fau.edu> wrote...[color=blue]
      > Fixed the "void" error, but the compiler still does not like the *****
      > marked line.[/color]

      (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];

      [color=blue]
      >
      >
      > "Victor Bazarov" <v.Abazarov@att Abi.com> wrote in message
      > news:vg0lla90qd i378@corp.super news.com...[color=green]
      > > "Sonoman" <fcarpio@REMOVE cse.fau.edu> wrote...[color=darkred]
      > > > 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[/color][/color]
      > just[color=green][color=darkred]
      > > > starting a new project and I cannot get past this (may be very simple)
      > > > error. My code is as follows:[/color]
      > >
      > > What does your compiler documentation say about that error?
      > > What line of code does the compiler complain about?
      > >
      > >[color=darkred]
      > > > /////////////////////////array.h
      > > > #ifndef array_h
      > > > #define array_h
      > > >
      > > > const int MAX = 10;
      > > >
      > > > class array
      > > > {
      > > > public:
      > > > array();
      > > > ~array();
      > > > run();[/color]
      > >
      > > A function declaration needs a return value type. Did you
      > > mean to write
      > >
      > > void run();
      > >
      > > ?
      > >[color=darkred]
      > > >
      > > >
      > > > private:
      > > > string playerNames[MAX];[/color]
      > >
      > > 'string' is most likely undefined here. Did you forget to
      > > include the right header?
      > >[color=darkred]
      > > > 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[i] = " ";
      > > > }
      > > > curTurn = 0;
      > > > numPlayers = 0;
      > > > }
      > > >
      > > > array::run()[/color]
      > >
      > > Again, a function definition should begin with the return
      > > value type. Did you mean to write
      > >
      > > void array::run()
      > >
      > > ???
      > >[color=darkred]
      > > > {
      > > > for (i = 0; i < MAX; i++)
      > > > {
      > > > playerNames[i] = " ";
      > > > }
      > > > 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.[/color]
      > >
      > > HTH
      > >
      > > Victor
      > >
      > >[/color]
      >
      >
      >[/color]


      Comment

      Working...