Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

I have a fixture class Foo, but TEST_F(Foo, Bar) gives me error “no matching function for call to Foo::Foo()”. Why?

0
Posted

I have a fixture class Foo, but TEST_F(Foo, Bar) gives me error “no matching function for call to Foo::Foo()”. Why?

0

Google Test needs to be able to create objects of your test fixture class, so it must have a default constructor. Normally the compiler will define one for you. However, there are cases where you have to define your own: • If you explicitly declare a non-default constructor for class Foo, then you need to define a default constructor, even if it would be empty. • If Foo has a const non-static data member, then you have to define the default constructor and initialize the const member in the initializer list of the constructor. (Early versions of gcc doesn’t force you to initialize the const member. It’s a bug that has been fixed in gcc 4.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.