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 6981771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:12:01+00:00 2026-05-27T18:12:01+00:00

I got this interface I’ve written: #ifndef _I_LOG_H #define _I_LOG_H class ILog { public:

  • 0

I got this interface I’ve written:

#ifndef _I_LOG_H
#define _I_LOG_H

class ILog {
public:
    ILog();
    virtual ~ILog();

    virtual void LogInfo(const char* msg, ...) = 0;
    virtual void LogDebug(const char* msg, ...) = 0;
    virtual void LogWarn(const char* msg, ...) = 0;
    virtual void LogError(const char* msg, ...) = 0;

private: 
    Monkey* monkey;
};

#endif

The methods are pure virtual and therefore must be implemented by deriving classes.
If I try to make a class that inherits this interface I get the following linker errors:

Undefined reference to ILog::ILog
Undefined reference to ILog::~ILog

I understand why there is a virtual destructor (to make sure the derived’s destructor is called) but I do not understand why I get this linker error.

EDIT: Okay, so I need to define the virtual destructor as well.
But can I still perform stuff in the definition of the virtual destructor, or will it simply call my derived classes destructor and skip it?
Like, will this trigger:

virtual ~ILog() { delete monkey; }
  • 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-05-27T18:12:02+00:00Added an answer on May 27, 2026 at 6:12 pm

    You haven’t defined the constructor and destructor, you have only declared them

    Try

    class ILog {
    public:
        //note, I want the compiler-generated default constructor, so I don't write one
        virtual ~ILog(){} //empty body
    
        virtual void LogInfo(const char* msg, ...) = 0;
        virtual void LogDebug(const char* msg, ...) = 0;
        virtual void LogWarn(const char* msg, ...) = 0;
        virtual void LogError(const char* msg, ...) = 0;
    };
    
    • Constructor: Once you declare a constructor, any constructor, the compiler doesn’t generate a default constructor for you. The constructor of the derived class tries to call the interface’s constructor and it is not defined, just declared. Either provide a definition, or remove the declaration
    • Destructor: Other considerations left alone (for example, similar considerations as above) your destructor is virtual. Every non-pure virtual function must have a definition (because it is by definition used).

    can I still perform stuff in the definition of the virtual destructor,
    or will it simply call my derived classes destructor and skip it?
    Like, will this trigger

    Yes you can. When the destructor of the derived class is called, it will automatically call the base class’s destructor. However there isn’t much I can think of that it would make sense to do in a destructor of an interface. But technically you can do anything in the destructor, even if it is virtual

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got a generic Interface like this : public interface IResourceDataType<T> { void SetResourceValue(T
I've got some objects which implement this interface: public interface IRow { void Fill(DataRow
I've got this setup in my code: public abstract class ModelBase{} public interface IModelbase<T>{}
Say I've got this interface: public interface IFoo { string Text {get;} } And
i just have a little design question. If i got this code public Interface
I have got this event in my page aspx.cs: public void deleteBtn_Click(object sender, CommandEventArgs
So lets say I have this interface: public interface IBox { public void setSize(int
I've got this class. .h: #import @class GLEngine; @interface opengl_engineAppDelegate : NSObject { //
I've got this code: Entry.h #import <Foundation/Foundation.h> @interface Entry : NSObject { id object;
Got this line of code here but its not working. private void Button_Click(object sender,

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.