0

So, I have this struct:

struct Articol
{
vector <char*> Nume;
char* Titlu;
int An;
vector <int> Pagini;
};

and this class:

class Bibliografie
{
int nr_art, nr_carti, nr_pagini;
vector <Articol> Articole;
};

and the following line of code:

cout << Object.Articole.Nume[j] << " ";

that generates this error:

error: ‘class std::vector<Articol>’ has no member named ‘Nume’

How can I fix that?

1 Answer 1

3

Articole is a std::vector and std::vector has no member Nume. The error is very clear. You need to get an element from the std::vector Articole:

Object.Articole[x].Nume[j]

Just make sure that element at index x exists (or use .at( or iterators or anything else, see std::vector here).

Sign up to request clarification or add additional context in comments.

2 Comments

Yeap, I have just figured that out. Dumb me..Thanks!
@epanicafrate no problem, feel free to mark as the correct answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.