如何在 VS Code 中为新项目创建模板,以便每次从模板创建新项目时,都会自动为我创建每个文件和文件内容。例如,我希望 VS Code 使我的新项目包含一个包含以下内容的 Makefile 文件:
console: main
./main
file: main
./main < input.txt > output.txt
main: main.cpp
g++ -g -O2 -std=gnu++17 -static main.cpp -o main
Run Code Online (Sandbox Code Playgroud)
连同3个文件,分别是main.cpp、input.txt和output.txt。
有没有办法在 C++ 中创建一个可以像 Python 一样使用的函数或宏?我的意思是一个函数,如:
print(i); // i is an integer.
print(i, s); // i is an integer, s is a std::string. They are separated by a white space.
Run Code Online (Sandbox Code Playgroud)
一个接受多个参数的函数,然后不管类型如何都将它们打印出来。