Results 1 to 8 of 8

Thread: having access to members and functions of a class from its subclass

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

    Default Re: having access to members and functions of a class from its subclass

    This has nothing to do with Qt. If you are writing in C++, it is a C++ question and you should look up C++ inheritance.

    If what you are asking is this kind of subclassing:

    Qt Code:
    1. class B
    2. {
    3. // ...
    4. };
    5.  
    6. class A : public B
    7. {
    8. // ...
    9. };
    To copy to clipboard, switch view to plain text mode 

    and you mean B needs to know about methods that are defined only in A, then how is this supposed to work? If you create an instance of class B and try to cast it to "A" and use A methods, your code will probably crash when you try to call A methods because an instance of B is not an instance of A even if you force the code to treat it that way.

    Maybe you should show some of your code where you are trying to do what you want, because the way I understand your question it doesn't make any sense.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. The following user says thank you to d_stranz for this useful post:

    QJak (2nd May 2018)

Similar Threads

  1. Why operator overloading functions can't be members of class
    By rawfool in forum General Programming
    Replies: 1
    Last Post: 31st October 2017, 16:53
  2. Replies: 2
    Last Post: 27th October 2013, 18:23
  3. Replies: 4
    Last Post: 17th January 2011, 14:05
  4. Replies: 1
    Last Post: 9th January 2011, 07:20
  5. Static functions and class members
    By Raistlin in forum General Programming
    Replies: 5
    Last Post: 22nd December 2006, 10:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.