在c/c++中的main()之前和之后打印一些内容
printing something before and after main() in c/c++
考虑代码片段
main()
{
cout << "Hello";
}
在不接触上述代码片段的情况下打印
嗨
你好
再见
#include <iostream>
using namespace std;
struct A
{
A() { cout << "Hi" << endl; }
~A() { cout << endl << "Bye"; }
};
A a;
main()
{
cout << "Hello";
}
实时演示链接。
#include <iostream>
using namespace std;
struct A
{
A() { cout << "Hi" << endl; }
~A() { cout << "nBye" << endl; }
};
A a;
int
// untouched part :)
main()
{
cout << "Hello";
}
输出为
Hi
Hello
Bye
相关文章:
- 如何循环打印顶点结构
- 为什么在popback()操作之后,它仍然打印完整的矢量
- 如何在c++中打印目录
- 有一个打印语句的函数是一种糟糕的编程实践吗
- 在线编译器中的分段C++没有打印消息
- 在类定义之后定义一个私有方法
- 在C++中打印指向不同基元数据类型的指针的内存地址
- 这个指针和内存代码打印是什么?我不知道是打印垃圾还是如何打印我需要的值
- 在循环C++中指定字符串之后,不会打印该字符串
- 我在 C++ 中创建了一个函数来递归反转字符串,但是之后如何使功能打印一个 endl?
- 打印C++中字符出现之间/之后的所有子字符串
- C++ 在地板函数之后以十六进制打印数字
- 如何在C ++中打印特定位数的位数?例如,总共打印8位数字(小数点之前+之后的组合)
- 我的 for 循环之后的代码不起作用,for 循环后的打印语句不会被打印
- 即使在空字符之后,垃圾值也会打印
- std::cout不';t在QNX中\n之后打印字母
- 使用流来打印点之后的最大十进制位置
- 在c/c++中的main()之前和之后打印一些内容
- 为什么在满足if语句之后,else语句仍然打印?
- 如何在c++中从endl之后开始打印