I tried to make simple program to catch and error by making function that divided an int to zero but i don't see the error neither the correct output
#include <iostream>
constexpr double division(int a, int b){
if(b == 0)
throw "Cannot be divides by zero";
return (a / b);
}
int main(){
int x {50};
int y {0};
int z {0};
z = x / y;
try{
z = division(x ,y);
std::cout << z << std::endl;
}catch (const char* msg) {
std::cerr << msg << std::endl;
}
return 0;
}
C:\Users\Tungki\Desktop\c>g++ jj.cc C:\Users\Tungki\Desktop\c>a C:\Users\Tungki\Desktop\c>
As you can see nothing happens here