Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>C++ Class Generator / UtilityNew to Visual Studio Code? Get it now.
C++ Class Generator / Utility

C++ Class Generator / Utility

Aydong

|
506 installs
| (1) | Free
Generate C++ class with header and source file, and generate getters and setters for class members ! Also generate tasks.json for C++ compilation with include path of all source files in the task !
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

GenClass - C++ Class Generator (by Aydong)

GenClass is a Visual Studio Code extension that allows you to quickly generate a C++ class along with its .h and .cpp files. This extension saves you time by automating the creation of these files directly within the VS Code file explorer.

Features

  • Generates a header file (.h) and a source file (.cpp) for a new C++ class.
  • Automatically adds the class constructor and destructor.
  • Uses the selected folder in the explorer to create the class files.
  • Accessible via the context menu (right-click) in the file explorer.
  • Automatically adds author and date information to the generated files.
  • Automatically includes the class header file in the source file.
  • Generates getter and setter methods for all member variables in the class.
  • Generates basic tasks.json file for including the all .cpp files in the compilation and laucnh a run without debug or debug mode (configurable).

How to Use

In Explorer

  1. Right-click on a folder in the VS Code file explorer.
  2. Select the "Create C++ Class" option from the context menu.
  3. An input box will appear, prompting you to enter the class name.
  4. The extension will automatically generate the .h and .cpp files in the selected folder with the following basic structure shown in the example section.

In File

  1. Right-click in the editor window.
  2. Select the "Create C++ Class" option from the context menu.
  3. An input box will appear, prompting you to enter the class name.
  4. The extension will automatically generate the .h and .cpp files in the same folder as the current file with the following basic structure shown in the example section.
  5. An input box will appear asking if you want to include the header file in the source file.

Generate Getters and Setters

  1. Open the header file (.h) of your class in the editor.
  2. Right-click in the editor window.
  3. Select the "Generate Getters and Setters" option from the context menu.
  4. The extension will automatically generate getter and setter methods for all member variables declared in the class, avoiding any duplicates.

Generate Tasks.json

  1. Right-click in your main file (.cpp) in the editor window.
  2. Select the "Generate Tasks.json" option from the context menu.
  3. The extension will automatically generate a tasks.json file
  4. And run your amazing code !

Example of Generated Class

Class Name : MyClass

MyClass.h

/* --- MyClass.h --- */

/* ------------------------------------------
author: {Your Username}
date: {Current Date}
------------------------------------------ */

#ifndef MYCLASS_H
#define MYCLASS_H

class MyClass {
public:
    MyClass();
    ~MyClass();

    int getValue();         // Example getter
    void setValue(int v);   // Example setter

private:
    int value;              // Example member variable

};

#endif // MYCLASS_H

MyClass.C++

/* --- MyClass.cpp --- */

/* ------------------------------------------
author: {Your Username}
date: {Current Date}
------------------------------------------ */
#include "MyClass.h"

MyClass::MyClass() {
    // Constructor
}

MyClass::~MyClass() {
    // Destructor
}

int MyClass::getValue() {
    return value;      // Getter implementation
}

void MyClass::setValue(int v) {
    value = v;        // Setter implementation
}
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft