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

  • Home
  • SEARCH
  • 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 1045089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:55:57+00:00 2026-05-16T15:55:57+00:00

Sorry but this is really confusing me and I know the answer is staring

  • 0

Sorry but this is really confusing me and I know the answer is staring at me in the face and I can’t figure it out. Could someone take a look? Its for a Airline Reservation System school project.

This function takes in the Flight Number, capacity, the count of the number of
flights, and the vector containing all of the flights as arguments.
It will check to make sure the flight does not exist, if it exists an error
message will be displayed, if not the flight will be created. The count for the
number of flights will also be incremented.

void newFlight( string f, string s, int* n, vector<Flight> *v)
{

    Flight temp;

    //Check to see if flight number exists
    bool alreadyExist = false;
    for (int i=0; i < v->size(); i++)
    {
        if (f.compare((v[i].getNumber()) == 0))
        alreadyExist = true;
    }

    //If it doesn't exist, create it
    if (!alreadyExist)
    {       
        v->push_back (temp);    //Add the new Flight object to the 
                                            //vector of flights
        *n++;           //Increase count
    }

    else
    {
        cout << "A flight numbered " << f << " already exists"; 
        cout << ". Flight not created.\n";
    }   

};

My problem is that when I try to compare the flight number the flights already in the vector with the one I am trying to add. On line 7 I keep getting this message:

error: ‘class std::vector<Flight, std::allocator<Flight> >’ has no member named ‘getNumber’

The vector in question is a vector with the Flight class which has a member named getNumber(). Im passing the vector to the function by reference. So v is a pointer, but I thought the [] would take care of that. Ive also tried using the -> operator instead of the dot operator but it doesn’t help. Im at a loss, any help would be appreciated. Im relatively rusty, the summer just finished 😀 Also I hope this is formatted correctly.

  • 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-05-16T15:55:58+00:00Added an answer on May 16, 2026 at 3:55 pm

    Argument v is passed to your function as a pointer to vector. If you then use the [] operator, it thinks, just as in C, that v is a pointer to an array of vectors, so v[i] is actually still a vector.

    What you should do is this:

    (*v)[i].getNumber();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sorry, but this keyword doesn't mean anything to me... Can someone give me
Sorry if this sounds like a really stupid question, but I need to make
Ok sorry this might seem like a dumb question but I cannot figure this
Surprisingly I've been unable to find anyone else really doing this, but surely someone
I'm sorry, but this is beginning to feel like kicking myself in the head.
Sorry for this not being a real question, but Sometime back i remember seeing
Sorry if this is a little off-topic for regular stackoverflow questions, but we're tearing
Sorry, if this is a noobish question, but I'm just getting started with Rails
Ok, I know this has been asked a thousand times before, but no conclusive
Well, sorry about the confusing title but I'm having a slightly annoying problem with

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.