Re: how to pass smart pointes to function.
From: Phlip (phlip_cpp_at_yahoo.com)
Date: 07/08/04
- Next message: Arijit: "Re: Is there anything in C++ akin to Java's class Object?"
- Previous message: Christopher Benson-Manica: "Re: Friend a good idea here?"
- In reply to: lokb: "how to pass smart pointes to function."
- Next in thread: lokb: "Re: how to pass smart pointes to function."
- Reply: lokb: "Re: how to pass smart pointes to function."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 08 Jul 2004 20:24:50 GMT
lokb wrote:
> I have a structure which and defined a smart pointer to the structure.
>
> /* Structure of Begin Document Index Record */
> typedef struct BDI_Struct{
> unsigned char rname;
> unsigned short int rlen;
> int code;
> short int reserved;
> char indexName[9];
> unsigned char tripLen;
> unsigned char tripCode;
> TRIPLET01 t01;
> }BDIStruct;
Why are you writing C style C++ code? Just say struct BDI_Struct.
> /* Structure of Index Element Record */
> typedef struct record{
> unsigned char rname;
> unsigned short int rlen;
> int code;
> short int reserved;
> unsigned char tripLen;
> unsigned char tripCode;
> union
> {
> TRIPLET01 t01;
> TRIPLET57 t57;
> TRIPLET2D t2D;
> TRIPLET36 t36;
> TRIPLET02 t02;
> TRIPLET80 t80;
> TRIPLETGEN tgen;
> }TRec;
> }IndexStruct;
Why are you using a union? Just list the members you need, and don't use all
of them at the same time.
The answers to both questions might well be "I'm matching a binary format
that someone else wrote". If so, ignore my complaints.
> Defined the smart pointer as below:
> where ObjVar returns the pointer.
> typedef ObjVar<IELStruct> IELStruct_sptr;
> typedef ObjVar<BDIStruct> BDIStruct_sptr;
>
> Now when i am passing the smart pointers to the function i get compilation
> errors
> I am passing the smart pointers as
>
> int vValidateIndModcaFile(ObjVar<BDIStruct>& bdirec,ObjVar<IndexStruct>&
> ielrec);
Why does vValidateIndModcalFile() have such a tortuous name?
Also, why does vValidateIndModcalFile() care how its BDIStruct and
IndexStruct are stored? Will it ever delete or re-seat the smart pointer's
object?
Just pass in the raw objects:
int vValidateIndModcaFile(BDIStruct & bdirec, IndexStruct & ielrec);
> I am getting the erros like
>
> "/vpapp/accenture/ISIXRelease1206302004/include/sptr.hpp", line 68.11:
> 1540-1101 (W) A return value of type "BDI_Struct *" is expected.
> "/vpapp/accenture/ISIXRelease1206302004/include/sptr.hpp", line 63.12:
> 1540-0700 (I) The previous message was produced while processing
> "ObjVar<BDI_Struct>::operator->()".
My suggestion will probably fix all that.
But you get operator->() errors from a smart pointer by writing something
like sp->method(). Your controlled objects have no methods, so if you still
have a problem post the code that actually appears inside
vValidateIndModcaFile().
-- Phlip http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces
- Next message: Arijit: "Re: Is there anything in C++ akin to Java's class Object?"
- Previous message: Christopher Benson-Manica: "Re: Friend a good idea here?"
- In reply to: lokb: "how to pass smart pointes to function."
- Next in thread: lokb: "Re: how to pass smart pointes to function."
- Reply: lokb: "Re: how to pass smart pointes to function."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|