Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8435925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:03:16+00:00 2026-06-10T07:03:16+00:00

I am trying to make a data tree that holds multiple data types and

  • 0

I am trying to make a data tree that holds multiple data types and vectors. What I have so far is shown below:

struct VertStruct{
    double X, Y, Z;
};
struct FaceStruct{
    int F1, F2, F3, F4;
};
struct FaceNormalStruct{
    double X, Y, Z;
};
struct LODStruct{
    std::vector<VertStruct> Verts;
    std::vector<FaceStruct> Faces;
    std::vector<FaceNormalStruct> FaceNormals;
};
struct ChunkStruct{
    std::vector<LODStruct> LOD;
};

int main(){

    std::vector<ChunkStruct> Chunk;
    Chunk.resize(100);

    for(int i = 0; i < 100; i++)
    {
        Chunk[i].LOD.resize(5);

        for(int j = 0; j < 5; j++)
        {
            Chunk[i].LOD[j].Verts.resize(36);
            Chunk[i].LOD[j].Faces.resize(25);
            Chunk[i].LOD[j].FaceNormals.resize(25);
        }
    }
return 1;
}

Now this compiles fine and is exactly what I want, however, if I try to set a value to something like:

int Number = 42;
Chunk[5].LOD[4].Verts[3] = Number;

Then I get the following error:

 main.cpp|126|error: no match for 'operator=' in 'Chunk.std::vector<_Tp, _Alloc>::operator[] [with _Tp = ChunkStruct, _Alloc = std::allocator<ChunkStruct>](5u)->ChunkStruct::LOD.std::vector<_Tp, _Alloc>::operator[] [with _Tp = LODStruct, _Alloc = std::allocator<LODStruct>](4u)->LODStruct::Verts.std::vector<_Tp, _Alloc>::operator[] [with _Tp = VertStruct, _Alloc = std::allocator<VertStruct>](3u) = Number'|

So am I missing something or is what I am attempting to do not possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:03:18+00:00Added an answer on June 10, 2026 at 7:03 am

    Verts[3] is of type VertStruct and Number is an int so the assignment is not possible (with the posted code). You could specify one of the members of VertStruct as the target of the assignment:

    Chunk[5].LOD[4].Verts[3].X = Number;
    

    If you wanted to be able to assign an int to a VertStruct you provide an operator=(int) (as mentioned already by Luchian) but it seems to me it would be quite ambiguous at the call site to what member(s) the int value is being assigned to:

    struct VertStruct
    {
        double X, Y, Z;
        VertStruct& operator=(int d)
        {
            X = d; // Or 'Y' or 'Z' or all.
            return *this;
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a decision tree using rpart using a data frame that
Trying to make a custom :confirm message for a rails form that returns data
I'm trying to make dynamic menu using xml data, I'm creating that menu using
I am trying to make a structure for a data packet that has a
I'm trying to make a cgridview that can filter data from relations table. This
I'm trying to make a script that automatically starts uploading after the data has
I have been trying to create a red black tree that only implements an
Let's say that I have an adt representing some kind of tree structure: data
I'm trying to inherit QSqlTableModel to make data im my table display in way
I'm trying to make a simple tabular data layout using a QTableView with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.