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 6892731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:34:17+00:00 2026-05-27T06:34:17+00:00

Inside of a class called Castle I have the following 2 functions: vector<Location> Castle::getMoves(Location***

  • 0

Inside of a class called Castle I have the following 2 functions:

vector<Location> Castle::getMoves(Location*** squares, Location* loc){
    int row = loc->getRow();
    int col = loc->getCol();

    vector<Location> moves;

    //problem is here!
    getVerticalMoves(squares, &moves, row, col);

    return moves;
}

void Castle::getVerticalMoves(Location*** squares, vector<Location*> * moves, int row, int col){
    //need to do something here, but can't call the function!
}

When I try to compile, I get an error that looks like this:

model/src/Castle.cpp: In member function ‘std::vector<Location> Castle::getMoves(Location***, Location*)’:
model/src/Castle.cpp:26:44: error: no matching function for call to ‘Castle::getVerticalMoves(Location***&, std::vector<Location>*, int&, int&)’
model/inc/Castle.h:38:8: note: candidate is: void Castle::getVerticalMoves(Location***, std::vector<Location*>*, int, int)
make: *** [model/obj/Castle.o] Error 1

I do not understand why this error is appearing. Why does it say that I am passing it references?

  • 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-27T06:34:18+00:00Added an answer on May 27, 2026 at 6:34 am

    Do you want a vector of Locations? Or do you want a vector of pointers to Locations? You need to pick one and stick with it.

    The reason it shows a reference is because if it showed just the value, that would suggest that you could not call a function that takes a reference, since a reference can appear on the left side of an equals sign and a value cannot. What you passed to the function can appear on the left side of an equals sign, so leaving off the & would make the error message less informative. (Suggesting perhaps your mistake was to pass a value where a modifiable reference was required.)

    Consider:

    int f1(int &j) { j++; return 3; }
    int f2(int j) { return j+1; }
    int q;
    
    f1(3); // not legal, we are passing an 'int' value and need an 'int' reference
    f2(3); // legal, passing an 'int' value function needs an 'int' value
    f1(q); // legal, we are passing an 'int&', function need an 'int&'
    f2(q); // legal, reference can be demoted to value
    

    So when you pass an lvalue (something that can appear on the left side of an equal sign), you really are calling the function with a reference — something more powerful than a mere value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class called Menu and inside that class I want to place
I have a class called JDChart, and a class called JDLine. Inside JDChart there
I have the following classes: Class called House (which have data regarding the house
I have a class called Website, and inside of that class I have the
I have a common project called common. Inside is a class called ExtensionMethods which
I have the following problem / bug: I made a custom button-class (called CustomBlitButton)
I have got a class called Customers with an Arraylist inside to store information
I have an instance of NSNumber * did inside a class called Reservation. Below
I have a Public Class called ClientConnection. Inside that class, I have a Public
Is there a way for a class called inside another to know the name

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.