Add types of error examples
This commit is contained in:
@ -0,0 +1,10 @@
|
|||||||
|
int test()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test(128);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
int test(); // Function signature
|
||||||
|
|
||||||
|
// The implementation fixes the link-build error
|
||||||
|
// in test()
|
||||||
|
// {
|
||||||
|
// return 10;
|
||||||
|
// }
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
int calculateArea(int width, in height)
|
||||||
|
{
|
||||||
|
return width * height;
|
||||||
|
}
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int area = calculateArea(-10, -12); // non-sensical because a rectangle can't have negative dimensions
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
#include <iostream>
|
||||||
|
int divide(int x, int y)
|
||||||
|
{
|
||||||
|
return x/y;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int div = divide(10, 0); // can't divide by zero
|
||||||
|
std::cout << div << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
int main()
|
||||||
|
{
|
||||||
|
int @!#* = 10;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user