TDocFile::TDocFile(TString FName)
{
printf("Ctor: Set up file %s\n",FName.Data());
Reset(FName);
}
and I derive another class from this (the ?? syntax error is intentional, i.e. this script shall abort)
TSpectrumFileTabular::TSpectrumFileTabular(TString FName)
:T??File(FName)
{
printf("TAB Ctor: Set up file %s\n",FName.Data());
}
I use the test code
TSpectrumFileTabular *DF = new TSpectrumFileTabular("Si_1s_3000.dat");
printf("Name of file is '%s'\n",DF->GetFileName().Data());
CINT, however, runs the script with the result:
[quote]root [12] .x tdocfiletest.c
Ctor: Set up file
(const class TDocFile)125492936
Ctor: Set up file
TAB Ctor: Set up file Si_1s_3000.dat
Name of file is ‘’[/quote]
From this I conclude that CINT does not pass parameter to the ancestor, and even does not deal with the line where the ancestor is expected to be.
Am I wrong here?
I am not sure it is warning-level problem. The functionality of the two constructors are quite different, so using constructor different from the one I intended, is definitely an error.
As far as I understand, CINT interpreter uses only the function definition, when compiling the dictionary, only the declaration is used. A pretty source of misterious errors, if the two are different.
[quote]I am not sure it is warning-level problem. The functionality of the two constructors are quite different, so using constructor different from the one I intended, is definitely an error.
[/quote]Per se you did not call any constructor, you called something named ‘T??File’. CINT should emit a message telling you that T??File does not exist.
[quote]As far as I understand, CINT interpreter uses only the function definition, when compiling the dictionary, only the declaration is used. A pretty source of misterious errors, if the two are different.[/quote]What do you mean? The Interpreter should use and check both the declaration and the implementation. The dictionary generator by definition should only use the declaration.
Hi Philippe,
I do agree with both of your ‘should’ statements. Please run the sample script I sent and you will see that CINT does not emit a message that T??File does not exist (from this I concluded that the part after ‘:’ is completely neglected). CINT also does not use the member function declaration: it does not notice a missing declaration (this is what you called as a kind of extension) and what is worse, does not notice if the declaration and implementation conflict.
[quote]CINT also does not use the member function declaration: [/quote]As I try to say … it does but with a twist. CINT has the extension that an implementation of method (even without an explicit declaration inside the class declaration) is equivelent to a declaration. So for CINT
class X {
void print(int);
};
void X::print(double);
is strictly equivalent to
class X {
void print(int);
void print(double);
};
void X::print(double);So the behavior in consistent and expected … even if it is not the same as the compiler. [At some point in the future we will get to the point where we have one or more switches to disable the extension].
[quote]Please run the sample script I sent and you will see that CINT does not emit a message[/quote]I know . My ‘should’ should have read “should but does not yet”!