Discussion Board

Results 1 to 2 of 2

Hybrid View

  1. #1
    Registered User raviroches's Avatar
    Join Date
    Oct 2007
    Posts
    14
    I have a class c which has instance of classes fs nad s.but will have one instance of class(either s or fs) at one time. The inline function foo returns object of s, in some cases need to return instance of fs using same function. Can any one help me how can i achive this. External class uses this finction to get information. Here only return type need to be different, depend on which class object is created at that time.

    class fs
    {}

    class s
    {}

    class c
    {
    public:
    inline s foo()
    {
    return s;
    }
    }

    Thanks and Regards,
    Ravikanth

  2. #2
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    The concrete return type has to be available in compilation time, so strictly said you can not do that. A thing you could do is returning a union of the two classes.
    You can also make s and fs to be relatives, and return pointers/refernces (const or non-const, depending on the use-case) to the higher level one - and provide a way to check what the actual object is.

    You can find more about C++ in a C++ book.

Similar Threads

  1. How to get the Major Device Class at Discovery Time
    By HansPrové in forum Bluetooth Technology
    Replies: 2
    Last Post: 2008-04-16, 13:32
  2. Page builder
    By giogiogio in forum Python
    Replies: 2
    Last Post: 2007-08-26, 18:08
  3. Replies: 2
    Last Post: 2007-03-14, 17:15
  4. Replies: 0
    Last Post: 2005-12-09, 14:12
  5. How to make singleton
    By rownak_hasan in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2003-02-06, 23:15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved