catch

失敗した話。

#include <string>

int main() {
    try {
        throw("");
    }
    catch(std::string e) {
        ;
    }
}

こんなコードで例外を捕えられませんでした。実際にはこれほど単純なコードではなかったのですが。無意識のうちにこういうコードから連想していたようです。

#include <string>
#include <iostream>

void print(std::string s) {
    std::cout << s << std::endl;
}

int main() {
    print("abc");
}