Ayushi Jain Ayushi Jain - 3 months ago 13
Python Question

No Matching function to call C++

I have 2 classes TreeManager and TreeProducerBase. I am getting an error in passing an object of TTree( which is a class to make trees) to a function in TreeProducerBase from TreeManagerconstructor.
Note : I have defined tree as

TTree *tree_

Function call :


Here, tpb is an object of TreeproducerBase class.

This is the function that is being called.

void initialize(TTree &tree_)

It shows the error as follows:

error: no matching function for call to 'TreeProducerBase::initialize(TTree*&)'

Where am I doing wrong?


You are trying to pass pointer-to-pointer-to-TTree to a function that expects reference-to-TTree. Try redeclare it like

void initialize(TTree* &tree_);

Invokation will look like


And then you can initialize outer pointer via simple assignment:

void initialize(TTree* &tree_) {
    tree_ = new TTree(); // or smth else