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

  • SEARCH
  • Home
  • 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 6096159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:53:39+00:00 2026-05-23T12:53:39+00:00

Using Visual Studio 2010 C++ with GMock. Trying to create a stub object for

  • 0

Using Visual Studio 2010 C++ with GMock. Trying to create a stub object for a third party class that is used by my classes but I’m getting the following error:

Error: object of abstract class type
“ThirdPartyClassFake ” is not allowed.

The third party class is defined like:

namespace ThirdPartyNamespace
{

class __declspec(novtable) ThirdPartyClass : public ThirdPartyBaseClass
{
public:
    virtual bool Hello() const = 0;
    virtual bool Goodbye() const = 0;
};

}

I created a mock of this:

namespace ThirdPartyNamespace {

class ThirdPartyClassFake : public ThirdPartyClass {
 public:
  MOCK_CONST_METHOD0(Hello, bool());
  MOCK_CONST_METHOD0(Goodbye, bool());
};
}

Now in my test I’m trying to do:

TEST(MyService, WhenCalled_DoesTheRightThingTM) {

    // Arrange
    ThirdPartyClassFake stub;

    // Act
    ...

    // Assert
    ...
}

The error is on the “ThirdPartyClassFake stub;” line. Why am I getting this error and how can I successfully create a mock/stub object?

  • 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-23T12:53:40+00:00Added an answer on May 23, 2026 at 12:53 pm

    Specifically the problem was that although I implemented ThirdPartyClass‘s virtual methods in my mock object, I neglected to implement ThirdPartyBaseClass‘s virtual methods. This was causing the error. Once I added MOCK_METHOD calls for those methods the error went away.

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

Sidebar

Related Questions

I'm using Visual Studio 2010. I'm trying to write simple Camera class in OpenGL.
Using Visual Studio 2010 when creating a wcf service the template creates a class
I'm using Visual Studio 2010 to create a Word Template. I created a Ribbon
I am using Visual Studio 2010 to create a Setup package to install a
I am using Visual Studio 2010 ultimate and have a solution that contains a
I'm using Visual Studio 2010 Ultimate, and it seems that I cannot suppress warnings
I'm using Visual Studio 2010. I have a class with the following constructor: CVideoAnnotation::CVideoAnnotation(std::string
Using Visual Studio 2010 beta, when I run my application within the IDE for
Using Visual Studio 2010, when I add the four IronRuby references to an existing
For a solo developer using Visual Studio 2010 beta 2 is TFS Basic a

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.