ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » How do I initiate a non-static MQMD variable?

Post new topic  Reply to topic
 How do I initiate a non-static MQMD variable? « View previous topic :: View next topic » 
Author Message
lifeng
PostPosted: Tue Jan 22, 2008 8:52 am    Post subject: How do I initiate a non-static MQMD variable? Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Tue Jan 22, 2008 9:05 am    Post subject: Reply with quote

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
View user's profile Send private message
lifeng
PostPosted: Tue Jan 22, 2008 9:24 am    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Tue Jan 22, 2008 9:25 am    Post subject: Reply with quote

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
View user's profile Send private message
RogerLacroix
PostPosted: Tue Jan 22, 2008 8:41 pm    Post subject: Re: How do I initiate a non-static MQMD variable? Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » How do I initiate a non-static MQMD variable?
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.