I have a class UDPSocketTest, which is derived from SocketTest. The SocketTest need an parameter in it's constructor.
Because of using the gtest framework, UDPSocketTest need to have an constructor without parameter, So I'd like to create it in constructor of UDPSocketTest, and pass it to SocketTest.
The problem is the base class is initialized before the member by C++ standard.
class UDPSocketTest : public SocketTest
{
public:
UDPSocketTest()
socketPool_(new SocketPool()), <<---- Line 1
SocketTest(socketPool_) { <<---- Line 2
}
~UDPSocketTest() {
}
private:
SocketPool* socketPool_;
};
But the Line 2 should be called before Line 1. So any way to implement this?
Aucun commentaire:
Enregistrer un commentaire