Error with GetNbinsX


I have the loop below for a TH1D histogram:

for(Int_t i=0; i<frac.GetXaxis()->GetNbinsX();i++) {
cout << frac.GetBinContent(i) << “,\t”;

and when I run my macro I get an error regarding GetNbinsX:

Error: Can’t call TAxis::GetNbinsX() in current scope tracks_ClusterPitch_errors.C:18:
Possible candidates are…
Error: non class,struct,union object GetXaxis() used with . or -> tracks_ClusterPitch_errors.C:18:
Error: Binary operator oprand missing tracks_ClusterPitch_errors.C:18:

What am i doing wrong?



Use hist.GetXaxis()->GetNbins()