Re: [語法] 請教一題有關ctor/dtor的問題
※ 引述《Crysis (Crysis)》之銘言:
: #include <iostream>
: int main()
: {
: std::cout<<"hello\n";
: return 0;
: }
: 題目是要求不動到main()的情況下
: 讓輸出變成
: Constructor xxxx //xxxx的字樣我忘記了, 整句是執行ctor的意思
: hello
: Destructor xxxx
: 猜測是要讓cout成為ostream的物件?
: 但實在想不出要怎麼改..所以來請教大家..
: 謝謝!
如果沒規定一定得用ctor/dtor
可以像下面這樣做
#include <iostream>
int main()
{
std::cout<<"hello\n";
return 0;
}
void bye()
{
std::cout<<"Destructor xxxx\n";
}
int init()
{
std::cout<<"Constructor xxxx\n";
atexit(bye);
}
int haha=init();
沒研究過0x的thread變數
不知道能不能這樣玩
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.252.66.243
推
11/15 00:09, , 1F
11/15 00:09, 1F
推
11/15 02:14, , 2F
11/15 02:14, 2F
→
11/15 02:21, , 3F
11/15 02:21, 3F
※ 編輯: loveflames 來自: 111.252.74.157 (11/15 05:31)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):