Use of NetworkInterface in an own class

Hi!

I have a class where I want to set iface as a private class variable, so that I can use iface. in different class methods e.g. init() method where I call iface = CellularContext::get_default_instance(); and then iface->set_default_parameters();.

class Cellular {
public:
    Cellular():
    ~Cellular();
    int init();
    ...
private:
    NetworkInterface *iface;
};

But I get errors on compile (static_cast). What do I’m wrong?

[Error] NetworkStack.h@455,31: static_cast from 'NetworkInterface **' to 'NetworkInterface *' is not allowed
[ERROR] In file included from ./cellular/Cellular.cpp:13:

Hello,

The iface is declared as a pointer to NetworkInterface. So when you’d like to call it’s method it shall be dereferenced with -> as follows:

//iface.set_default_parameters();
iface->set_default_parameters();
1 Like

Hi @hudakz!

That’s true. I had written it wrong here in the forum. Sorry. But the problem is not solved anyway. :sweat:

The error comes from #include "Cellular.h" where I define NetworkInterface *iface; in class private section.

Hi! I have solved the problem. It was a bad reference in later part of the code.