Add types of error examples

This commit is contained in:
Lev
2021-08-31 22:56:15 -05:00
parent 8db42d2564
commit 3cbb1de4ff
5 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,10 @@
int test()
{
return 1;
}
int main()
{
test(128);
return 0;
}

View File

@ -0,0 +1,13 @@
int test(); // Function signature
// The implementation fixes the link-build error
// in test()
// {
// return 10;
// }
int main()
{
test();
return 0;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -0,0 +1,5 @@
int main()
{
int @!#* = 10;
return 0;
}