Create C++ Member Function in Visual Studio

Mryam Girmay

We are excited to announce that Create C++ Member Function can now be used to quickly add constructor and equality operator (operator ==) in Visual Studio 17.6 Preview 2. When you have a class with fields, you can add a default constructor, constructor with all fields, equality operator, and equality operator with all fields easily.

Three dots will appear below a class name to indicate that you can add a member function, and you can hover over them to see the quick action (screwdriver icon). When the default constructor and equality operator are added respectively, the Go to Definition of the operator== is displayed below, showing that the body of the equality operator would have nothing inside it. 

An example of creating C++ member function without fields.

You can also choose to add a constructor with all fields and an equality operator with all fields respectively, and the Go to Definition will show that the operator== has all the field comparisons.    

An example of creating C++ member function with all fields included.

Future Work

This experimental feature will be improved by adding more functions that can save you a lot of typing. Right now, it includes constructor and equality operator (operator==) only, and we are considering adding more cases, such as assignment, swap, and hash, and would like to hear your feedback whether you are interested in these coming in future versions. 

We have a Developer Community ticket to Improve “Create Member Function”, if you have the same suggestions make sure to upvote it.  

Send us your feedback! 

Download the latest version of Visual Studio Preview and give the Create C++ Member Function feature a try. Your feedback will be extremely helpful in shaping this experience, therefore, please continue to send your feedback in the comments below or/and via Developer Community. You can also reach us on Twitter (@VisualC), or via email at visualcpp@microsoft.com.   

3 comments

Discussion is closed. Login to edit/delete existing comments.

  • Peter Nimmo 0

    Doesn’t work for me at all, I tried it previously in 17.6 Preview 2.0 and no … appears, I try it again today after downloading the latest update to the preview 17.7 Preview 3, and still no dots appear under the class.

    I have looked to see if it had to be enabled in Product Features but there is no checkbox to tick

    • Mryam GirmayMicrosoft employee 0

      You’re right, it’s enabled by default and there is no tools option to enable/disable it. Have you tried restarting your system or clearing the cache to see if that helps?

  • Adi Gostin 2

    How do I disable this?

Feedback usabilla icon