Talk About Network

Google





Programming > C - C++ Learning > Function that r...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 4134 of 4400
Post > Topic >>

Function that returns an address?

by Pat <pkelecy@[EMAIL PROTECTED] > May 2, 2008 at 05:09 PM

I'm going through some C++ code that someone else wrote trying to 
understand it.  One part I have some questions about is the following:

//*****************************************************
static UDPPrimitiveTypeInfo primitiveInfo =
{
	"Rectangular Spiral",
	"Create a Rectangular Spiral in XY plane",
	"Ansoft Cor****ation",
	"01-01-2004",
         "1.0"
};

extern "C" DLLEX****T

UDPPrimitiveTypeInfo* GetPrimitiveTypeInfo()
{
     return &primitiveInfo;
}
//*****************************************************

The first part is clear.  It's just defining a static structure, 
"primitiveInfo" of type "UDPPrimitiveTypeInfo" which contains a number 
of character fields.

The second part (extern "C" DLLEX****T) I'm not so sure about.  What does 
it do?

The last part is what I'm mainly questioning.  If I understand this 
correctly, it looks like it's a function that returns a pointer to a 
structure (I believe that's what "UDPPrimitiveTypeInfo*" type is 
specifying), and the return value is the address of the previously 
defined structure, "primitiveInfo".  - Is that correct?

If so, wouldn't it be easier to just assign the address directly, ie.

   UDPPrimitiveTypeInfo * GetPrimitiveTypeInfo = &primitiveInfo;

rather than use a function?  Is there some benefit to using a function?

Thanks for any feedback on this.
 




 8 Posts in Topic:
Function that returns an address?
Pat <pkelecy@[EMAIL PR  2008-05-02 17:09:17 
Re: Function that returns an address?
Ian Collins <ian-news@  2008-05-03 09:14:30 
Re: Function that returns an address?
Pat <pkelecy@[EMAIL PR  2008-05-03 11:57:08 
Re: Function that returns an address?
"Jim Langston"   2008-05-02 15:59:53 
Re: Function that returns an address?
Pat <pkelecy@[EMAIL PR  2008-05-03 11:56:12 
Re: Function that returns an address?
Barry Schwarz <schwarz  2008-05-02 23:55:09 
Re: Function that returns an address?
Pat <pkelecy@[EMAIL PR  2008-05-03 12:05:41 
Re: Function that returns an address?
Barry Schwarz <schwarz  2008-05-03 21:51:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Fri Jan 9 6:15:47 PST 2009.