如何为 "compile and run" 编写 bash 别名?

How to write a bash alias for "compile and run"?

我在 linux 下并且总是 运行 我的测试程序是这样的:

g++ MyFileName.cpp -std=c++11 && ./a.out

我不想打这么多字,我想在我的 .bashrc 中写一个 bash 别名,命名为 c++运行,这样我就可以:

c++run MyFileName.cpp

编译成功,运行 ./a.out

这样的别名怎么写?如果不行,写一个bash函数?

使用函数代替别名或脚本。 tinycc 也可以做你想做的事,据我所知。