Re: one simple question

From: Faz (faz_at_volcanomail.com)
Date: 11/12/03


Date: Wed, 12 Nov 2003 12:41:24 -0000


"Thomas Matthews" <Thomas_MatthewsHatesSpam@sbcglobal.net> wrote in message
news:ZA23b.34584$Vx2.15008322@newssvr28.news.prodigy.com...
> Asif wrote:
[]
> > I have been trying to understand the behaviour of char (*pfn)(null)
> > for a couple of days. can some body help me understand the behaviour
> > of char (*pfn)(null) in Visual C++ environment?
[]

You'll most likely find a macro called NULL in one of the Visual C++
headers.

> The declaration:
> char (*pfn)(null);
> is of a pointer to a function taking a "null" type and
> returning a type of char. To my understanding, there is no
> type of "null" in _standard_ C++.

Yes, there is no such type..
 No, this doesn't declare a function.

It *would* if "null" were replaced by, say, "float" (which IS a type), or by
"double x" (a type and a name).
Empty brackets would be equivalent to replacing the "null" with "void", ie
also making this a function declaration (like your example later).

The NULL macro often supplied with some compilers means the brackets would
contain a value, hence this would declare a simple char* whose value is 0,
if the OP had uppercased it.
(As it stands its a syntax error :-)

BTW Stroustrup (5.1.1) discourages use of a NULL macro and recommends
instead to use the literal 0 to indicate that the pointer doesn't refer to
an object (leads to fewer problems).

[]
> One cannot assign the value from a "pointer to function" to a
> "pointer to variable".

Not without coercion via an evil cast, true.

("Trust the programmer"..)

-Faz



Relevant Pages

  • Re: Compiler error occurred when try to use a flexible template expression in preprocessor definesCo
    ... I want to expand the function declaration from a typelist such like ... I want to declare a macro which can automatic decides which macro ...
    (comp.lang.cpp)
  • Re: Declaring Objects
    ... What this is saying is set the Colors variable to refer to the Colors sheet, ... > that I need to declare my objects and know that I would prefer to declare ... > Below is my first attempt to writing a macro, ... > Sub FindAndReplace() ...
    (microsoft.public.excel.programming)
  • Re: Converting C to Delphi
    ... macro and a million constants. ... Can this be imported into delphi or do I ... > Perform those calculations yourself and declare the constants with the ... One is temp, ...
    (alt.comp.lang.borland-delphi)
  • Re: Loop problem
    ... (declare (special a b)) ... will need a macro to type in the nest of dolists for you. ... The macroexpander will say "Oh I'm not finished yet." ...
    (comp.lang.lisp)
  • Re: VBA Word 2003 File Close
    ... It would be better to declare a variable as a Document and set that variable to the document that you are opening rather than rely on the active document. ... In a Word 2003 template document I have a macro triggered by a CheckBox ... document and then is supposed to close that second document. ... I get a run-time error 4198 "Command Failed" at the line that ...
    (microsoft.public.word.vba.general)