×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    8

    passing arguments

    Hi,

    I have two classes and I want to pass argument between them. What is the easiest way to do this?

    I've tried to pass a reference to object of first class to a constructor of the second class, but actually I don't know how to do this exactly.

    Any ideas?

    Thanks for replies,
    Justyna

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: passing arguments

    Quote Originally Posted by niff111 View Post
    I've tried to pass a reference to object of first class to a constructor of the second class, but actually I don't know how to do this exactly.

    Any ideas?
    Learn C++.
    Code:
    class CSecondClass : public CBase
    {
    public:
        CSecondClass(CFirstClass &aFirstObject);
    
    private:
        CFirstClass &iFirstObject;
    };
    
    CSecondClass::CSecondClass(CFirstClass &aFirstObject)
    :iFirstObject(aFirstObject)
    {}

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    8

    Re: passing arguments

    but when I pass it to NewL() like this I get error "illegal use of non static member"
    What does it mean?

  4. #4
    Regular Contributor
    Join Date
    Apr 2008
    Location
    India
    Posts
    477

    Re: passing arguments

    Quote Originally Posted by niff111 View Post
    but when I pass it to NewL() like this I get error "illegal use of non static member"
    What does it mean?
    Can u plz provide us the definition and signature of NewL() and the point fromwhr u called it...

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: passing arguments

    Obviously if you have NewL/C, it has to be static.

  6. #6
    Registered User
    Join Date
    Jan 2009
    Posts
    8

    Re: passing arguments

    Here is my NewL:

    Code:
    CSearchListContainer* CSearchListContainer::NewL(CMPKSearch5Container &cont) 
    :iMPKSearch5Container(cont)
        {
        CSearchListContainer* self = CSearchListContainer::NewLC();
        CleanupStack::Pop(self);
        return self;
        }
    Carbide returns:
    Code:
    ';' expected
    declaration syntax error
    make returned with exit value = 2
    error is in first line in code i've posted

  7. #7
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,355

    Re: passing arguments

    Don't confuse the static NewL and NewLC methods with constructors, they are not. Instead make sure that &const gets down to the real constructor where it can be passed to the member variable.

    Code:
    CSearchListContainer* CSearchListContainer::NewL(CMPKSearch5Container &cont) 
        {
        CSearchListContainer* self = CSearchListContainer::NewLC(cont);
        CleanupStack::Pop(self);
        return self;
        }
    
    CSearchListContainer* CSearchListContainer::NewLC(CMPKSearch5Container &cont) 
        {
        CSearchListContainer* self = new (ELeave) CSearchListContainer(cont);
        CleanupStack::PushL(self);
        self->ConstructL();
        return self;
        }
    
    CSearchListContainer::CSearchListContainer(CMPKSearch5Container &cont)
    :iMPKSearch5Container(cont)
    {
    }
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  8. #8
    Nokia Developer Champion
    Join Date
    Jul 2004
    Posts
    2,015

    Re: passing arguments

    I don't wish to be rude but you simply can't program in Symbian without a very very slow and painful and irritating experience if you do not know C++.

    You need to at least read a C++ book.

  9. #9
    Registered User
    Join Date
    Jan 2009
    Posts
    8

    Re: passing arguments

    Thank you all, now it's working.

Similar Threads

  1. passing command line arguments
    By UncleOp in forum Open C/C++
    Replies: 0
    Last Post: 2008-06-10, 17:27
  2. passing arguments in asyncronous server
    By mearunsingh in forum Symbian
    Replies: 7
    Last Post: 2008-05-25, 22:18
  3. Replies: 2
    Last Post: 2008-03-26, 15:59
  4. Replies: 2
    Last Post: 2007-04-25, 09:52
  5. Passing arguments
    By franalegre in forum Symbian User Interface
    Replies: 0
    Last Post: 2003-04-23, 11:30

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •