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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:27:05+00:00 2026-06-08T15:27:05+00:00

Just learning C++, encountered an issue that i’m not really sure why the following

  • 0

Just learning C++, encountered an issue that i’m not really sure why the following is the case.

Doesn’t work

ChildObject in = myObject.getObjFromVector(0);
ChildObject out = myObject.getObjFromVector(1);
doSomething(in.property, out.property); // void doSomething(Thing &in, Thing &out)

where 
ChildObject& getObjFromVector(int index)

Works

process(myObject.getObjFromVector(0).property, myObject.getObjFromVector(1).property);

In case your wondering, though i don’t think its relevant, Thing is Mat from opencv. This question however is about why the above works in one way but not the other.

Interestingly Which is more performant, passing a method the entire object, or a property of that object? suggests that both should work, or at least be acceptable. I’m definately doing something wrong though and this might be down to something in openCV i’m not aware off.

edit:
I’m effectively carrying out some image manipulation on the .property value. like

process (Mat &src, Mat &out){
...
pyrDown(src, result, Size(src.cols / 2, src.rows / 2));
...

WHen its not working, i’m not seeing the pyrDown take effect.

  • 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-08T15:27:06+00:00Added an answer on June 8, 2026 at 3:27 pm

    This is possibly due to object slicing (I am not familiar with openCV). In the first example:

    ChildObject in = myObject.getObjFromVector(0); 
    

    a copy is made of object referred to by the return value of getObjFromVector() as in is of type ChildObject, not ChildObject&.

    The second example passes the reference returned directly to the function so no object slicing occurs.

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

Sidebar

Related Questions

Just learning how to work with php and mysql, using CodeIgniter. Running into that
Im just learning javascript and I'm just wondering why this doesn't work. I've created
Just learning php and looking into someone else's code. I'm not sure what is
I'm just learning about SVG, and it seems great but I'm not sure about
Hi I have just started learning WCF and I have encountered an error I
I'm just learning MVC3 now and this is really confusing me. I have a
I'm just learning nHibernate and have come across what probably is a simple issue
I am just learning Rails. I had encountered a routing error, though I think
I've just begun learning Unix and have so far encountered two elementary though difficult
I'm just learning java and following a book. I have a program written via

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.