Passing anobject of aclass an an argument to the funtion

A

Amit_Basnak

Dear friends

I have to pass the objec of a class which is a part of afunction in
thefunction call.
my code looks like this now

#include <iostream.h>
#include <waspc/common.h>
#include <waspc/runtime/Runtime.h>
#include "WFWuList.h"
using std::cout;
using std::cerr;
using std::endl;
class WFStructSearch;
ArrayOfWFWuStructFe WfListWuClnt(
WFWuHandle,
char* process_id,
char* process_step_id,
char* cluster_id,
WFStructSearch *search_params,
char* incl_active_wu,
int nbr_requested
);

int main (int argc,char *argv[]) {
WASP_Runtime::clientInitialize ();
try {
WASP_Runtime::clientStart("conf/client-core.xml", NULL);
WFWuList a;
ArrayOfWFWuStructFe ret;
WFStructSearch search;
ret = a.WfListWuClnt( NULL, process_id, process_step_id, cluster_id,
::WFStructSearch &search, incl_active_wu, nbr_requested));
cout << "There are " << numElements << " elements in the table"
<< endl;
}
catch (WASP_Exception *exc) {
char *trace=GET_TRACE (exc);
cerr << "Exception during call: " << exc->getCharMessage() <<
endl;
cerr << "Stack trace follows: " << endl << trace << endl;
delete[] trace;
delete exc;
}
WASP_Runtime::clientTerminate();
return 0;
}
-----------------------------------------------------------------------------------------------------------------------------------------
The required function is
ArrayOfWFWuStructFe WfListWuClnt(
WFWuHandle,
char* process_id,
char* process_step_id,
char* cluster_id,
WFStructSearch *search_params,
char* incl_active_wu,
int nbr_requested
);

I have already declared a class
class WFStructSearch;
search_params is the pointer to it.
And my function call is
ret = a.WfListWuClnt( NULL, process_id, process_step_id, cluster_id,
::WFStructSearch &search, incl_active_wu, nbr_requested));

And I am passing ::WFStructSearch &search in it, Kindly let me know if
is the right way of passing to a function call

Thanks
Amit
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

Dear friends

I have to pass the objec of a class which is a part of afunction in
thefunction call.
my code looks like this now

#include <iostream.h>
#include <waspc/common.h>
#include <waspc/runtime/Runtime.h>
#include "WFWuList.h"
using std::cout;
using std::cerr;
using std::endl;
class WFStructSearch;
ArrayOfWFWuStructFe WfListWuClnt(
WFWuHandle,
char* process_id,
char* process_step_id,
char* cluster_id,
WFStructSearch *search_params,
char* incl_active_wu,
int nbr_requested
);

int main (int argc,char *argv[]) {
WASP_Runtime::clientInitialize ();
try {
WASP_Runtime::clientStart("conf/client-core.xml", NULL);
WFWuList a;
ArrayOfWFWuStructFe ret;
WFStructSearch search;
ret = a.WfListWuClnt( NULL, process_id, process_step_id, cluster_id,
::WFStructSearch &search, incl_active_wu, nbr_requested));
cout << "There are " << numElements << " elements in the table"
<< endl;
}
catch (WASP_Exception *exc) {
char *trace=GET_TRACE (exc);
cerr << "Exception during call: " << exc->getCharMessage() <<
endl;
cerr << "Stack trace follows: " << endl << trace << endl;
delete[] trace;
delete exc;
}
WASP_Runtime::clientTerminate();
return 0;}-----------------------------------------------------------------------------------------------------------------------------------------
The required function is
ArrayOfWFWuStructFe WfListWuClnt(
WFWuHandle,
char* process_id,
char* process_step_id,
char* cluster_id,
WFStructSearch *search_params,
char* incl_active_wu,
int nbr_requested
);

I have already declared a class
class WFStructSearch;
search_params is the pointer to it.
And my function call is
ret = a.WfListWuClnt( NULL, process_id, process_step_id, cluster_id,
::WFStructSearch &search, incl_active_wu, nbr_requested));

And I am passing ::WFStructSearch &search in it, Kindly let me know if
is the right way of passing to a function call

The ::WFStructSearch should not be there, just &search, just as if you
had an int called foo and wanted to pass that to a function that takes
a pointer to an int you would write &foo.
 
A

Amit_Basnak

Erik said:
Dear friends

I have to pass the objec of a class which is a part of afunction in
thefunction call.
my code looks like this now

#include <iostream.h>
#include <waspc/common.h>
#include <waspc/runtime/Runtime.h>
#include "WFWuList.h"
using std::cout;
using std::cerr;
using std::endl;
class WFStructSearch;
ArrayOfWFWuStructFe WfListWuClnt(
WFWuHandle,
char* process_id,
char* process_step_id,
char* cluster_id,
WFStructSearch *search_params,
char* incl_active_wu,
int nbr_requested
);

int main (int argc,char *argv[]) {
WASP_Runtime::clientInitialize ();
try {
WASP_Runtime::clientStart("conf/client-core.xml", NULL);
WFWuList a;
ArrayOfWFWuStructFe ret;
WFStructSearch search;
ret = a.WfListWuClnt( NULL, process_id, process_step_id, cluster_id,
::WFStructSearch &search, incl_active_wu, nbr_requested));
cout << "There are " << numElements << " elements in the table"
<< endl;
}
catch (WASP_Exception *exc) {
char *trace=GET_TRACE (exc);
cerr << "Exception during call: " << exc->getCharMessage() <<
endl;
cerr << "Stack trace follows: " << endl << trace << endl;
delete[] trace;
delete exc;
}
WASP_Runtime::clientTerminate();
return 0;}-----------------------------------------------------------------------------------------------------------------------------------------
The required function is
ArrayOfWFWuStructFe WfListWuClnt(
WFWuHandle,
char* process_id,
char* process_step_id,
char* cluster_id,
WFStructSearch *search_params,
char* incl_active_wu,
int nbr_requested
);

I have already declared a class
class WFStructSearch;
search_params is the pointer to it.
And my function call is
ret = a.WfListWuClnt( NULL, process_id, process_step_id, cluster_id,
::WFStructSearch &search, incl_active_wu, nbr_requested));

And I am passing ::WFStructSearch &search in it, Kindly let me know if
is the right way of passing to a function call

The ::WFStructSearch should not be there, just &search, just as if you
had an int called foo and wanted to pass that to a function that takes
a pointer to an int you would write &foo.


Thanks Erik
I have corrected the error , now I am mydeclaration is
ArrayOfWFWuStructFe WfListWuClnt( WFWuHandle,
char* process_id,
char* process_step_id,
char* cluster_id,
WFStructSearch *search_params,
char* incl_active_wu,
int nbr_requested );

And the call is
ret = a.WfListWuClnt( NULL,
process_id,
process_step_id,
cluster_id,
&search,
incl_active_wu,
nbr_requested);
When I compile I am getting the error " Undeclared variable
'nbr_requested'.
Since it is included in my method declaration, how come it gives
undeclared error .
Thanks for your time
Amit
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

I have corrected the error , now I am mydeclaration is
ArrayOfWFWuStructFe WfListWuClnt( WFWuHandle,
char* process_id,
char* process_step_id,
char* cluster_id,
WFStructSearch *search_params,
char* incl_active_wu,
int nbr_requested );

And the call is
ret = a.WfListWuClnt( NULL,
process_id,
process_step_id,
cluster_id,
&search,
incl_active_wu,
nbr_requested);
When I compile I am getting the error " Undeclared variable
'nbr_requested'.
Since it is included in my method declaration, how come it gives
undeclared error .

It will be declared in the method body, but it is not declared where
you call your function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top