473,396 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What is the meaning of these lines?

nas

Hi..Please tell me what is the meaning of these lines

static IFastString *(*pfnlr)(const char *)=0

and

IFastString *(**ppfn)(const char *)=pfnlr

Where IFastString is the abstract class

May 22 '07 #1
5 2556
nas wrote:
Hi..Please tell me what is the meaning of these lines

static IFastString *(*pfnlr)(const char *)=0
pfnlr is a pointer to a function.

- start from the inside and read out - like this

pfnlr ->Is A

* pfnlr -pointer

(* pfnlr)(...) -to a function

(* pfnlr)(const char *) -that takes a const char * as a parameter

* (* pfnlr)(const char *) -and returns a pointer

IFastString *(*pfnlr)(const char *) -to an IFastString

static IFastString *(*pfnlr)(const char *) -it's got static storage

static IFastString *(*pfnlr)(const char *)=0 -and init to nul

e.g. The above definition is the same as:

typedef IFastString *(* T)(const char *);

static T pfnlr = 0;

In this case the "= 0" initialization is implicit for static so it's not
needed.
>
and

IFastString *(**ppfn)(const char *)=pfnlr
That would be the same as.

T * ppfn = pfnlr; // probably an error

.... should be

T * ppfn = & pfnlr;
>
Where IFastString is the abstract class
It's irrelevant what IFastString is in this discussion.
May 22 '07 #2
nas
On May 22, 3:11 am, Gianni Mariani <gi3nos...@mariani.wswrote:
nas wrote:
Hi..Please tell me what is the meaning of these lines
static IFastString *(*pfnlr)(const char *)=0

pfnlr is a pointer to a function.

- start from the inside and read out - like this

pfnlr ->Is A

* pfnlr -pointer

(* pfnlr)(...) -to a function

(* pfnlr)(const char *) -that takes a const char * as a parameter

* (* pfnlr)(const char *) -and returns a pointer

IFastString *(*pfnlr)(const char *) -to an IFastString

static IFastString *(*pfnlr)(const char *) -it's got static storage

static IFastString *(*pfnlr)(const char *)=0 -and init to nul

e.g. The above definition is the same as:

typedef IFastString *(* T)(const char *);

static T pfnlr = 0;

In this case the "= 0" initialization is implicit for static so it's not
needed.
and
IFastString *(**ppfn)(const char *)=pfnlr

That would be the same as.

T * ppfn = pfnlr; // probably an error

... should be

T * ppfn = & pfnlr;
Where IFastString is the abstract class

It's irrelevant what IFastString is in this discussion.
Thank you soo much for ur reply...But now i have another question to
ask..
e.g. The above definition is the same as:

typedef IFastString *(* T)(const char *);
How is this possible?? I think syntax of the type def should be for
ex:

typedef int NINT... So whenever you write NINT, compiler replaces NINT
with int..

But in your case
typedef IFastString *(* T)(const char *);

static T pfnlr = 0;
How does complier work?

May 22 '07 #3
nas wrote:
On May 22, 3:11 am, Gianni Mariani <gi3nos...@mariani.wswrote:
>typedef IFastString *(* T)(const char *);

How is this possible?? I think syntax of the type def should be for
ex:

typedef int NINT... So whenever you write NINT, compiler replaces NINT
with int..
you declare an int variable as

int a;

and a function pointer as

IFastString *(* a)(const char *);

as gianni explained. In the same way, you typedef an int as:

typedef int T;

and typedef a function pointer as:

IFastString *(* T)(const char *);

the syntax is specular. After the last typedef, the compiler will
replace every

T a;

with

IFastString *(* a)(const char *);

Regards,

Zeppe
May 22 '07 #4
nas
On May 22, 4:05 am, Zeppe
<zep_p@.remove.all.this.long.comment.yahoo.itwrote :
nas wrote:
On May 22, 3:11 am, Gianni Mariani <gi3nos...@mariani.wswrote:
typedef IFastString *(* T)(const char *);
How is this possible?? I think syntax of the type def should be for
ex:
typedef int NINT... So whenever you write NINT, compiler replaces NINT
with int..

you declare an int variable as

int a;

and a function pointer as

IFastString *(* a)(const char *);

as gianni explained. In the same way, you typedef an int as:

typedef int T;

and typedef a function pointer as:

IFastString *(* T)(const char *);

the syntax is specular. After the last typedef, the compiler will
replace every

T a;

with

IFastString *(* a)(const char *);

Regards,

Zeppe
problem solved!!! thanks for all of u

May 22 '07 #5
nas
On May 22, 4:05 am, Zeppe
<zep_p@.remove.all.this.long.comment.yahoo.itwrote :
nas wrote:
On May 22, 3:11 am, Gianni Mariani <gi3nos...@mariani.wswrote:
typedef IFastString *(* T)(const char *);
How is this possible?? I think syntax of the type def should be for
ex:
typedef int NINT... So whenever you write NINT, compiler replaces NINT
with int..

you declare an int variable as

int a;

and a function pointer as

IFastString *(* a)(const char *);

as gianni explained. In the same way, you typedef an int as:

typedef int T;

and typedef a function pointer as:

IFastString *(* T)(const char *);

the syntax is specular. After the last typedef, the compiler will
replace every

T a;

with

IFastString *(* a)(const char *);

Regards,

Zeppe
problem solved!!! thanks for all of u

May 22 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

112
by: Andy | last post by:
Hi All! We are doing new development for SQL Server 2000 and also moving from SQL 7.0 to SQL Server 2000. What are cons and pros for using IDENTITY property as PK in SQL SERVER 2000? Please,...
4
by: David List | last post by:
I'm working on a analyzation/design project that is supposed to uncover the intricacies and implications in entering the market for systems used by public administrations here in Denmark. XML...
9
by: rick cameron | last post by:
TimeZone - the only instance you can get is one representing the local time zone DateTime - cannot represent a time before 00:00:00 1 Jan 1 CE What were they thinking? This is a serious question...
44
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
1
by: SM | last post by:
I found a COM interop code sample and came across these lines of code: What do those type of lines encapsuled in brackets do? I already tried to find an answer using web search but no...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
132
by: Frederick Gotham | last post by:
If we look at a programming language such as C++: When an updated Standard comes out, everyone adopts it and abandons the previous one. It seems though that things aren't so clear-cut in the C...
3
by: nas | last post by:
Hi..Please tell me what is the meaning of these lines static IFastString *(*pfnlr)(const char *)=0 and IFastString *(**ppfn)(const char *)=pfnlr Where IFastString is the abstract class
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.