diff --git a/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/compile-error.cpp b/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/compile-error.cpp new file mode 100644 index 0000000..a8d88fe --- /dev/null +++ b/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/compile-error.cpp @@ -0,0 +1,10 @@ +int test() +{ + return 1; +} + +int main() +{ + test(128); + return 0; +} \ No newline at end of file diff --git a/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/link-error.cpp b/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/link-error.cpp new file mode 100644 index 0000000..2fa0faf --- /dev/null +++ b/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/link-error.cpp @@ -0,0 +1,13 @@ +int test(); // Function signature + +// The implementation fixes the link-build error +// in test() +// { +// return 10; +// } + +int main() +{ + test(); + return 0; +} \ No newline at end of file diff --git a/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/non-error.cpp b/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/non-error.cpp new file mode 100644 index 0000000..a7150c8 --- /dev/null +++ b/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/non-error.cpp @@ -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; +} \ No newline at end of file diff --git a/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/runtime-error.cpp b/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/runtime-error.cpp new file mode 100644 index 0000000..6466a20 --- /dev/null +++ b/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/runtime-error.cpp @@ -0,0 +1,12 @@ +#include +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; +} \ No newline at end of file diff --git a/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/syntax-error.cpp b/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/syntax-error.cpp new file mode 100644 index 0000000..3daa23c --- /dev/null +++ b/CM2010 Software Design and Development/Topic 4/11.2.1 Types of errors/syntax-error.cpp @@ -0,0 +1,5 @@ +int main() +{ + int @!#* = 10; + return 0; +} \ No newline at end of file