{
"Header File": {
"prefix": "header", // 触发这个代码片段的关键字
"body": [
"#ifndef ${TM_FILENAME_BASE}_H", // 使用文件名作为宏
"#define ${TM_FILENAME_BASE}_H", // 使用文件名作为宏
"",
"class ${TM_FILENAME_BASE} {", // 定义类
"public:", // 公有成员
"\t${TM_FILENAME_BASE}();", // 构造函数声明
"\t~${TM_FILENAME_BASE}();", // 析构函数声明
"\tvoid SomeFunction();", // 示例成员函数声明
"};",
"",
"#endif // ${TM_FILENAME_BASE}_H"
],
"description": "Create a header file with include guards and a basic class structure"
},
"CPP File": {
"prefix": "cppfile", // 触发这个代码片段的关键字
"body": [
"#include \"${TM_FILENAME_BASE}.h\"", // 引入对应的头文件
"",
"${TM_FILENAME_BASE}::${TM_FILENAME_BASE}() {", // 构造函数
"\t// TODO: Implement constructor", // TODO 注释
"}",
"",
"${TM_FILENAME_BASE}::~${TM_FILENAME_BASE}() {", // 析构函数
"\t// TODO: Implement destructor", // TODO 注释
"}",
"",
"void ${TM_FILENAME_BASE}::SomeFunction() {", // 示例成员函数
"\t// TODO: Implement SomeFunction", // TODO 注释
"}"
],
"description": "Create a cpp file with corresponding header included and a basic class structure"
}
}
VSCode创建头文件和源文件的snippet
于 2024-11-12 10:09:40 首次发布