Missing compiler error for undefined struct methods

 

I have something like this, which works as usual:

struct TradeSettings{
   string            msg;
  
   void              toString() const;
}
// method implementation defined outside of struct body
TradeSettings::toString(){
    return msg;
}

However, if I have something like this, I would expect the compiler to return an error because no toString() method is defined (and the structure does not allow virtual methods):

struct TradeSettings{
   string            msg;
   
   // no implementation of toString()
   void              toString() const;
}
// no method implementation defined outside of struct body

To the maintainer of MQL5: Why doesn't this type of code trigger no compiler error? It would be better if the compiler threw an error, because without an error, there's a risk of forgetting to implement a struct method (which would then lead to a runtime error).


Such code 

 
harryma23:
To the maintainer of MQL5: Why doesn't this type of code trigger a compiler error?

Because you don't call that method anywhere.

(I'm not a "maintainer of MQL5", whatever that means)

 
harryma23:

I have something like this, which works as usual:

However, if I have something like this, I would expect the compiler to return an error because no toString() method is defined (and the structure does not allow virtual methods):

To the maintainer of MQL5: Why doesn't this type of code trigger no compiler error? It would be better if the compiler threw an error, because without an error, there's a risk of forgetting to implement a struct method (which would then lead to a runtime error).


Such code 

Because your method isn't called, so the compiler skip it.
 
Alain Verleyen #:
Because your method isn't called, so the compiler skip it.
Ok, thanks.