|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How do I initiate a non-static MQMD variable? |
« View previous topic :: View next topic » |
Author |
Message
|
lifeng |
Posted: Tue Jan 22, 2008 8:52 am Post subject: How do I initiate a non-static MQMD variable? |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
Hi,
My C++ program access MQ through API. I need to define and initiate a MQMD object to work with. I don't want this object to be static and I want to initiate it to MQMD_DEFAULT. So, to do this, I have code like this:
public class MyClass
{
public:
MQMD md;
...
MyClass()
{
md = {MQMD_DEFAULT}; // <= error C2059: syntax error
}
...
}
When I tried to initiate md in the constructor, I got the syntax error above. I can use the same syntax to initiate md if I make it a static variable and do the initiation out side of the class definition. But, unfortunately, I can't use static variable and it is also important that md to be initiated with MQMD_DEFAULT. I looked at the MQMD_DEFAULT and found that it is a big complex data structure. I don't want to use a big loop or something like that just to do the initiation. So what do I do? Do I have other options other than loop through the date structure one piece at a time?
Please execuse my ignorance. I must say that I am new on both MQ API and C++.
Thank you in advance!
Lifeng |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jan 22, 2008 9:05 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I think you need to use new. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
lifeng |
Posted: Tue Jan 22, 2008 9:24 am Post subject: |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
Thank you for your response!
Use new? But how? I tried both "md = new {MQMD_DEFAULT};" and "md = new MQMD_DEFAULT;", if that's what you mean, but they didn't help. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jan 22, 2008 9:25 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Neither of those are classes.
Please examine the manuals, particularly the helpfully titled "Using C++".
Please examine the samples that come with the product. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
RogerLacroix |
Posted: Tue Jan 22, 2008 8:41 pm Post subject: Re: How do I initiate a non-static MQMD variable? |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
lifeng wrote: |
public class MyClass
{
public:
MQMD md;
...
MyClass()
{
md = {MQMD_DEFAULT}; // <= error C2059: syntax error
}
...
} |
Hummm. That smells like a mixing of C and C++ code.
To access the MD, you should be doing it the OO way.
i.e.
Code: |
ImqMessage msg;
...
msg.setMessageId( );
msg.setCorrelationId( );
msg.setFormat( MQFMT_STRING ); |
As Jeff mentioned, please the Using C++ manual.
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|