Problem with TF2 and Axes

Dear Root-Experts,

I am using a TF2-object (ROOT 5.22) and would like to manipulate the axes. A simple example code reads as follows

void test()
{
TF2* func = new TF2(“func”,“x*y”,0,1,0,1);
func->GetXaxis()->SetTitle(“test axis title”);
func->Draw();
}

But this gives me always this error message

Error: C++ exception caught C:\root\macros\test.cpp(4)
Error: illegal pointer to class object GetXaxis() 0x0 143 C:\root\macros\test.cpp(4)

If I delete the line where I try to set the axis title it is running without errors. I have tested it several root versions as well as several operating systems.

Thanks in advance for your reply
Tom

Do:

TF2* func = new TF2("func","x*y",0,1,0,1); func->Draw(); func->GetXaxis()->SetTitle("test axis title");

Rene