VS14 CTP – Implement Pure Virtuals

This refactoring option implements stub-functions for all pure virtuals in one or all base classes. Here’s an example.

class Person
{
public:

  virtual std::string GetName() = 0;
  virtual void SetName(std::string) = 0;
};

class DbEntity
{
public:
  virtual int GetId() = 0;
  virtual void SetId(int) = 0;
};

class Employee : Person, DbEntity
{
public:
  Employee();
};

If you right click on a specific base class, you’ll get an option to just implement pure virtuals for that class. If you right click on the derived class name, you’ll get the option to implement all pure virtuals for all base types.

imppurevirts

This is what you’ll end up with (in the header).

class Employee : Person, DbEntity
{
public:
  Employee();
  // Inherited via Person

  virtual std::string GetName() override;

  virtual void SetName(std::string) override;

  // Inherited via DbEntity

  virtual int GetId() override;

  virtual void SetId(int) override;

};

Corresponding definitions (empty ones) will be generated in the cpp file.

Advertisement
Posted in C++

One thought on “VS14 CTP – Implement Pure Virtuals

  1. Hi Nish,

    I need your help to implement one Video Server which will boradcast video feed on RTSP using c++.

    Kindly provide me your contact detail for this.

    Thank You,
    Maulik Dusara

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s