Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8494655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:21:35+00:00 2026-06-10T23:21:35+00:00

I have a class Packet with an abstract method getID : Type Packet =

  • 0

I have a class Packet with an abstract method getID:

Type
  Packet = class
    ...
    function getID() : Integer;virtual;abstract;
    class procedure writePacket(par0 : Packet; par1 : TIdTCPConnection);
    ...
implementation 

class procedure Packet.writePacket(par0 : Packet; par1 : TIdTCPConnection);
// par1 is a TCP connection used to send data through the network; 
begin
  par1.writeInteger(par0.getID());
  //some code following 
end;

I have the following subclass:

type
  PacketTest = class(Packet)
    ...
    function getID() : Integer;
    ...

function PacketTest.getID():Integer;
begin
  result := {some value individual for each subclass}
end;

Now I call the superclass’s class procedure writePacket with a subclass of packet as par0, which should then call the subclass’s function getID.
Instead it calls the superclass’s function getID and (of course) throws an abstract error.

I want it to dynamically call the subclass’s function getID, which should never cause a problem because par0 is always a subclass of Packet since Packet itself is abstract.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:21:36+00:00Added an answer on June 10, 2026 at 11:21 pm

    The declaration of getID in the subclass must have the override keyword:

    type
      PacketTest = class(Packet)
        function getID: Integer; override;
      end;
    
    function PacketTest.getID: Integer;
    begin
      Result := {some value individual for each subclass}
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have classes which are inherited from abstract Packet( this class has abstract method
I have Packet class contains virtual method and I have LogInRequest class which extends
In my application I have a PacketList class and Packet class. I'd like to
We have class lua. In lua class there is a method registerFunc() which is
I have a class Packet which contains a Header object. From the header object,
I have, for my game, a Packet class, which represents network packet and consists
I have one supertype defined as: public abstract class AType<T> { .... private T
I have a class that my client uses to Get() a packet. The packet
I have a base class called Packet : // Header File class Packet {
If you have the following class as a network packet payload: class Payload {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.