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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:17:08+00:00 2026-06-17T20:17:08+00:00

I have a member function in my base class which takes argument by reference:

  • 0

I have a member function in my base class which takes argument by reference:

// Base
template<class Data, class Variable_Type = double>
class Parallel_Data
{
...
void FuncA(Data& data, int& Global_ID) 
{Data_Local.push_back(data); Local_To_Global_ID.push_back(Global_ID);};
}

// Derived
class Derived: public Parallel_Data<Atom_Placed>

The problem is when I try to call that function in the derived member functions

Push_Back_This_CPU(Atom_Placed(Position_Atom), Global_ID);

I get following error

no known conversion for argument 1 from ‘Atom_Placed’ to ‘Atom_Placed&’

I am just trying to pass the argument by reference and don’t know why it wants to convert?

  • 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-17T20:17:09+00:00Added an answer on June 17, 2026 at 8:17 pm

    Temporaries like Atom_Placed(Position_Atom) cannot bind to non-const references such as the parameter Atom_Place&. The reason is that they are temporary objects and will die any moment now.

    You could make a local variable of type Atom_Placed and pass that to the function Push_Back_This_CPU

    Atom_Placed tmp(Position_Atom);
    Push_Back_This_CPU(tmp, Global_ID);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class ( EAGLView ) which calls a member function of a
Imagine I have a class Window with a member function show which causes the
I have a template class with a variadic template member function that I am
Possible Duplicate: Can a member function template be virtual? In a base class, the
I know it sounds awefully confusing, I have a base template class which has
I have a class template which inherits from a base class template. The base
I have an expensive function defined in a base class, which depends on low
I have a member function in a class that has a callback, but the
I have an inline member function defined under class MyClass int MyClass::myInlineFunction(); This function
I wonder if it is a good practice to have a member template function

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.