Change Xaxis binning

Dear experts,
I have 2 hists (h1 and h2) and I after I created h1, and before I fill it, I want to change it’s xaxis such that it has same bin, xmin, xmax values then h2. Does such clone exist?
If not, is there a simple way to do that?
If not I try to found a method like: h1-> GetXaxis()->SetNbins()
but I did not saw any SetNbins(). Is it possible to do that?

h1= new TH1D(hname.c_str(), htitle.c_str(), 100, -5, 5);

So if you do not have fill h1 yet why don’t you create immediately with the right binning ?
The h2’s binning parameters can easily been retrieved from h2 (all getters are available).
Or you can even Clone h2.

Dear Couet,

you are right. I did this and it works fine.