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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:53:55+00:00 2026-06-07T10:53:55+00:00

I am using someone elses function that takes: optimise(std::vector<double> &input) It edits the input.

  • 0

I am using someone elses function that takes:

optimise(std::vector<double> &input)

It edits the input.

How should I pass a vector to this, I have tried:

std::vector<double> input;
input.push_back('several points');
optimise(input);

This has a linker error saying:

undefined reference to optimise(std::vector<double, std::allocator<double> >&)

If i try this:

 std::vector<double> &input;
input.push_back('several points');
optimise(input);

Then there is a compile error:

'input' declared as reference but not initialised

How do I initialise a reference to the vector or am I doing something completely wrong.
EDIT:

I wasn’t linking a library correctly in my CMakeLists. Thanks for everyone’s help, i wish i could mark you all as correct.

  • 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-07T10:53:59+00:00Added an answer on June 7, 2026 at 10:53 am

    Your first way of passing the vector is correct. The compiler recognizes that the vector is passed to the function by reference from the signature in the header, makes a reference to your vector, and passes it to the function. The fact that you see linker errors tells you that the compile stage completed successfully.

    The linker error is there because you are failing to include the library where the optimise function is implemented.

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

Sidebar

Related Questions

I'm using someone elses class and that person has defined a function with five
There is some code that I am using written by someone else that I
I am working on maintaining someone else's code that is using multithreading, via two
I am working on an Outlook add-in written by someone else using VSTO 4.0.
i am trying to validate someone else's code here and they are using the
Can someone please clarify using a SIMPLE user story the full slice of what
Can someone confirm this: If I am using PDO::PARAM, I don't need to Filter
Can someone tell me whether MSMQ (using transactions) supports competing consumers? Basically, I have
Can someone please help me with using Regex with NSPredicate? NSString *regex = @(?:[A-Za-z0-9]);
Could someone tell me the advantages to using the ConfigurationManager class which load's 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.