CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Implement....

  1. #1
    Join Date
    Dec 2000
    Posts
    163

    Implement....

    Hello.

    I have two classes:
    ClassA (Include 2 method: M1, M2)
    ClassB (Include Implement of ClassA + New Method M3)

    In my program I define the class (as written in MSDN) like this:

    Dim ObjA as ClassA
    Dim ObjB as new ClassB

    set ObjA = ObjB




    The problem is that ObjA don't recognize the method M3 !!!
    What can I do ???

    Thanks for any help.



  2. #2
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: Implement....

    I think this is because ObjA is ClassA type and not ClassB type. Therefore, it only knows M1 and M2 eventhough in the memory M3 does exist. At least this is how it works in C++.

    -Cool Bizs

    Good Luck,
    -Cool Bizs

  3. #3
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Implement....

    If you say implement, are you using the implements keyword? If so, youre actually using an interface. In this case, class A may not include any code, just de declaration of the methods. You will have to write your own implementation of M1 and M2 in class b, but they can be refferenced by an object of class A, but only the methods described in class a.

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured