Mail Archives: djgpp/1998/10/25/16:31:36
On Sat, 24 Oct 1998 20:55:29 -0600, bowman wrote:
>
>
>Mike Ruskai wrote:
>>
>> >int main(void)
>> >{
>> > MyClass instance(); // point of interest
>> > instance.say_hi();
>> >}
>> This is bad because you're declaring a function instead of defining a
>> variable.
>
>sigh. yes, one too many cut and pastes. Make that three ways not to do
>it.
>It is interesting that one can declare a function returning MyClass,
>never define or
>use it, and the compiler never says a word, while it will emit warnings
>for used
>variables.
That would be annoying in the extreme. Do you really want to see a warning
for every header file that declares but not defines functions (e.g. the
entire C library)? Compilers can remove unreferenced functions, and if you
do refer to it, the linker will complain about an unresolved external.
I never enable warnings about unused variables, personally.
--
- Mike
Remove 'spambegone' to send e-mail.
- Raw text -