简体   繁体   中英

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 :

tpb.initialize(&tree_); 

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

tpb.initialize(tree_);

And then you can initialize outer pointer via simple assignment:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM