From 93bfd9d3675318a218880b94b3f49471891f332f Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 29 Feb 2024 20:46:14 -0600 Subject: [PATCH] Added a virtual destructor to the Sock class, which would allow Server and Client to override it --- includes/sock.hpp | 3 +++ sock.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/includes/sock.hpp b/includes/sock.hpp index c5529c1..c34cabe 100644 --- a/includes/sock.hpp +++ b/includes/sock.hpp @@ -34,6 +34,9 @@ public: /* Default constructor */ Sock() {} + /* Virtual destructor */ + virtual ~Sock(); + /* Regular constructor - defined in sock.cpp */ Sock(int ip_ver, char protocol, const char* address, int port); diff --git a/sock.cpp b/sock.cpp index e6d4efc..ffcb778 100644 --- a/sock.cpp +++ b/sock.cpp @@ -13,6 +13,10 @@ void Sock::create_socket() { addrlen = sizeof(*dest); } +/* Virtual destructor, allows 'Server' and 'Client' to override this destructor */ +Sock::~Sock() {} + + /* Constructor - This function initializes the object attributes with the given parameters. It throws an exception if an IPv4 address was given, but the type given is IPv6 (or the other way around). */