小编Dav*_*ave的帖子

在try\finally块中是否存在这样的情况,最终将不会被执行?

我正在攻读面向对象编程的测试,我想知道是否有任何案例,考虑到以下代码:

try {
    do something
} catch (someException e) {

} finally {
    do something
}
Run Code Online (Sandbox Code Playgroud)

finally块不会执行?

java exception finally try-catch-finally

13
推荐指数
2
解决办法
1437
查看次数

模板函数错误:找不到哪个操作符采用类型的右手操作数

嘿! 看看下面的例子..它几乎是一些cpp书的复制粘贴.我无法理解为什么不编译(在Windows下).它说:

'<<' : no operator found which takes a right-hand operand of type 'div_t' (or there is no acceptable conversion)  
Run Code Online (Sandbox Code Playgroud)

这是一个例子:

#include <iostream>

template <class T>
T div(T a, T b) {
    T result =  a/b;
    return result;
}

int main() {    
    int a = 5;
    int b = 3;
    std::cout << "INT " << div(a,b) << std::endl; //this line output the error

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

谢谢!!

c++

1
推荐指数
1
解决办法
601
查看次数

标签 统计

c++ ×1

exception ×1

finally ×1

java ×1

try-catch-finally ×1