Click here to Skip to main content
15,890,973 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello, I want to use a GUID in my class.

1) I want to give it a default value in the default constructor (something like 0, NULL, etc). How can I do it?

2) In another constructor, I want to give it a default value in a case the call for the constructor dont have it. for example:

the constructor: MY_CLASS(int a, int b, int c = 0, GUID g = ???)
the call: MY_CLASS m = new MY_CLASS(5,3);

How can i do it?

Thanks
Posted

1 solution

Default value of a GUID: GUID_NULL, or IID_NULL (it is alias of GUID_NULL)


GUID_NULL is a GUID set to zero. Here's a string representation '{00000000-0000-0000-0000-000000000000}'
typedef struct _GUID
{
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} GUID;
const GUID GUID_NULL = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
 
Share this answer
 
Comments
user_code 12-Apr-11 1:52am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900