Class not compiling with TCanvas as argument of Template

Hi,

I am using a macbook air with osx 10.9.5 and root v 5.34. I attached a small class, when I do .L Tree.cxx+ I get:

Undefined symbols for architecture x86_64: "TCanvas::TCanvas(TCanvas const&)", referenced from: G__Tree_cxx_ACLiC_dict_3379_0_3(G__value*, char const*, G__param*, int) in Tree_cxx_ACLiC_dict.o G__Tree_cxx_ACLiC_dict_3378_0_3(G__value*, char const*, G__param*, int) in Tree_cxx_ACLiC_dict.o G__Tree_cxx_ACLiC_dict_3377_0_3(G__value*, char const*, G__param*, int) in Tree_cxx_ACLiC_dict.o G__Tree_cxx_ACLiC_dict_3376_0_3(G__value*, char const*, G__param*, int) in Tree_cxx_ACLiC_dict.o G__Tree_cxx_ACLiC_dict_3375_0_3(G__value*, char const*, G__param*, int) in Tree_cxx_ACLiC_dict.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Error in <ACLiC>: Compilation failed!

But when I comment:

template class Tree<int,TCanvas>; template class Tree<float,TCanvas>; template class Tree<double,TCanvas>; template class Tree<short,TCanvas>; template class Tree<unsigned,TCanvas>;

It works, I am not sure what is different in TCanvas from TH1F or TF1. Could you please take a look at it?

Thanks.
Tree.h (607 Bytes)
Tree.cxx (2.15 KB)

There’s no “Copy Constructor” in the TCanvas class.
A simple fix … in the “Tree.h” instead of “void Save(U obj);” use “void Save(U &obj);” and in the “Tree.cxx” instead of “void Tree<T,U>::Save(U obj)” use “void Tree<T,U>::Save(U &obj)”.
Another simple fix … in the “Tree.h” instead of “void Save(U obj);” use “void Save(U *obj);” and in the “Tree.cxx” instead of “void Tree<T,U>::Save(U obj)” use “void Tree<T,U>::Save(U *obj)” and then instead of “obj.Write();” use “obj->Write();”.

Hi,

Thanks for your quick reply, yes it works. I also saw that you made the copy constructor private, why TCanvas should not have a copy constructor?

Thanks.