当我开始学习如何测试一个程序时,我学到的就是用与测试程序相同的语言使用一个库或包。例如,
- if a tested program is written in Python, its testing program is also written in Python and uses `UnitTest` class in the python standard library
- if a tested program is written in C++, its testing program is also written in C++ and uses some test
我是(以及C++和C家族的新手)。
如何预览cpp文件的输出?
例如,如果我编写这个脚本
#include <iostream>
int main() // does 'int main' mean start the body (Like HTML's <body> ?
{
std::cout << "Hello World! "; // prints Hello World!
std::cout << "I'm a C++ program"; // prin
我试图用C++为我的简单语言编写一个编译器,但是我不确定当所讨论的语言声明一个用户定义的类时,我应该如何声明一个用户定义的类。
例如,在这种假定的语言中,用户写道:
CLASS Foo {
int bar;
}
我的编译器将如何读到这一点,然后在C++中生成相应的内容?然后,我希望编译器在C++中执行以下代码:
class Foo {
int bar;
}
语法是相同的。这在C++中是可能的吗?