struct error

B

Brad Tilley

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.
 
B

Brad Tilley

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
 
8

88888 Dihedral

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.
 

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,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top