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

Thread: class extension

  1. #1
    Join Date
    Sep 2011
    Posts
    197

    class extension

    I am trying to call a class, and I keep getting a construct instead why? Is there a reason why this would keep happening? Just a list of some basic reason why this happens would be appriciated.

  2. #2
    Join Date
    May 2011
    Posts
    41

    Re: class extension

    could you supply the code that's giving you trouble and the result.

  3. #3
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: class extension

    How are you "calling" a class? Do you mean you are trying to create an instance of the class?
    Or to call a method in a class?
    Norm

  4. #4
    Join Date
    Jan 2011
    Posts
    24

    Re: class extension

    Quote Originally Posted by kolt007 View Post
    I am trying to call a class, and I keep getting a construct instead why? Is there a reason why this would keep happening? Just a list of some basic reason why this happens would be appriciated.
    Can you provide some more details e.g. how are you calling class, what error are you getting , better paste the error it would be quick to solve.

  5. #5
    Join Date
    Sep 2011
    Posts
    197

    Re: class extension

    First class:

    Code:
     public class client extends Player implements Runnable { 
      //code here
    }
    Second class:
    Code:
     public class OBJECTS2 extends client {
    //code here
    }

    Error Thrown:
    Code:
    OBJECTS2.java:2: error: constructor client in class client cannot be applied to
    given types;
    public class OBJECTS2 extends client {
           ^
      required: Socket,int
      found: no arguments
      reason: actual and formal argument lists differ in length
    1 error
    Finished!
    Press any key to continue . . .

  6. #6
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: class extension

    You need to post all of the code for all of the classes. Your edited,shortened code samples are useless.
    Norm

  7. #7
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: class extension

    This code compiles with no errors:
    Code:
    public class InheritanceTest {
       class Player {}
       class client extends Player implements Runnable { 
         //code here
         public void run(){}
       }
         class OBJECTS2 extends client {
       //code here
       }
    }
    Norm

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