看板 C_and_CPP 關於我們 聯絡資訊
※ 引述《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
chrisdar:http://codepad.org/XmBex1nY 我想到的是這樣 11/15 00:09
softwind:@@" 就直接這樣給答案歐... 11/15 02:14
loveflames:反正題目要的是ctor/dtor,不能拿這個當答案 11/15 02:21
※ 編輯: loveflames 來自: 111.252.74.157 (11/15 05:31)