struct error

Discussion in 'C++' started by Brad Tilley, Feb 6, 2012.

  1. Brad Tilley

    Brad Tilley Guest

    I'm experimenting with using a struct within a vector located in a
    different struct. I'm getting a compiler error. Here are the
    structures:

    struct shelf_item
    {
    std::string name;
    int weight;
    };

    struct shelf
    {
    std::string location;

    // compiler error occurs here
    std::vector<shelf_item>;
    };

    The compiler error reads: "a template-id may not appear in a using-
    declaration"

    Standard types (string, int, etc.) work fine, but my struct doesn't.
    There's likely a better way to approach this, but having never tried
    it before I wanted to ask here. Not sure it matters, but I'm using g++
    4.6.2.

    Thanks for any advice.
    Brad Tilley, Feb 6, 2012
    #1
    1. Advertising

  2. Brad Tilley

    Brad Tilley Guest

    On Feb 6, 3:32 pm, Brad Tilley <> wrote:
    > I'm experimenting with using a struct within a vector located in a
    > different struct. I'm getting a compiler error. Here are the
    > structures:
    >
    > struct shelf_item
    > {
    >     std::string name;
    >     int weight;
    >
    > };
    >
    > struct shelf
    > {
    >     std::string location;
    >
    >     // compiler error occurs here
    >     std::vector<shelf_item>;
    >
    > };
    >
    > The compiler error reads: "a template-id may not appear in a using-
    > declaration"
    >
    > Standard types (string, int, etc.) work fine, but my struct doesn't.
    > There's likely a better way to approach this, but having never tried
    > it before I wanted to ask here. Not sure it matters, but I'm using g++
    > 4.6.2.
    >
    > Thanks for any advice.



    It's late and I made a typo... I figured it out:

    std::vector<shelf_item> si;

    Sorry for the noise.

    Brad
    Brad Tilley, Feb 6, 2012
    #2
    1. Advertising

  3. Copying any object stored as a tree like data structures of more than two digit
    levels is really slow for the spread blocks in the heap space.


    Anyway DRAM is getting cheap so fast, thus the operator reloading is getting
    cheaper more and more in the 16 to 64 giga heap sace and the tera bytes
    in the HD.
    88888 Dihedral, Feb 7, 2012
    #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.
Similar Threads
  1. RA Scheltema
    Replies:
    3
    Views:
    392
    RA Scheltema
    Jan 6, 2004
  2. Gunnar G

    struct in struct

    Gunnar G, May 31, 2004, in forum: C++
    Replies:
    14
    Views:
    797
  3. DanielEKFA
    Replies:
    8
    Views:
    601
    DanielEKFA
    May 16, 2005
  4. James Harris
    Replies:
    4
    Views:
    1,382
    James Harris
    Oct 9, 2003
  5. Chris Fogelklou
    Replies:
    36
    Views:
    1,370
    Chris Fogelklou
    Apr 20, 2004
Loading...

Share This Page