Passing anobject of aclass an an argument to the funtion

Discussion in 'C++' started by Amit_Basnak, Jan 11, 2007.

  1. Amit_Basnak

    Amit_Basnak Guest

    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
     
    Amit_Basnak, Jan 11, 2007
    #1
    1. Advertising

  2. On Jan 11, 5:59 am, "Amit_Basnak" <> wrote:
    > 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.

    --
    Erik Wikström
     
    =?iso-8859-1?q?Erik_Wikstr=F6m?=, Jan 11, 2007
    #2
    1. Advertising

  3. Amit_Basnak

    Amit_Basnak Guest

    Erik Wikström wrote:
    > On Jan 11, 5:59 am, "Amit_Basnak" <> wrote:
    > > 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.
    >
    > --
    > Erik Wikström



    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
     
    Amit_Basnak, Jan 11, 2007
    #3
  4. On Jan 11, 10:12 am, "Amit_Basnak" <> wrote:
    > Erik Wikström wrote:
    > > 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.

    >
    > 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.

    --
    Erik Wikström
     
    =?iso-8859-1?q?Erik_Wikstr=F6m?=, Jan 11, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alfred E Neuman
    Replies:
    3
    Views:
    281
    Alfred E Neuman
    Nov 4, 2003
  2. Lee Xuzhang
    Replies:
    5
    Views:
    355
    Kevin D. Quitt
    Jun 14, 2006
  3. Replies:
    10
    Views:
    619
    Tim Rentsch
    Nov 10, 2008
  4. trans.  (T. Onoma)
    Replies:
    6
    Views:
    147
    trans. (T. Onoma)
    Oct 1, 2004
  5. Kevin Blount

    passing a function name to another funtion

    Kevin Blount, Apr 21, 2006, in forum: Javascript
    Replies:
    15
    Views:
    159
    Kevin Blount
    May 10, 2006
Loading...

Share This Page