0

What is difference compiling error and runtime error

And give example

13th Aug 2017, 6:29 PM
$h@dow
$h@dow - avatar
2 Respostas
+ 5
A compile error happens when you try to compile or build a project/code but it fails. Runtime error occurs AFTER you compiled/build the project and you were clicky on buttons on your application and suddenly it crashes. Example: (any OOP lang) Compile error int x = 0 //no semi colon Runtime: public void sumthing(){ Int[] x = new {1, 2}; //Error will only occur when you call this function //Also, its out of bound index error. int y = x[3]; }
13th Aug 2017, 6:36 PM
Wen Qin
Wen Qin - avatar
+ 4
Compiler time errors occur before the code is executed. When a computer begins to compile your code, it turns the high-level language you wrote into machine code. If it cannot properly translate your code into machine code, you receive a compiler-time error. For example, if I write something that has incorrect syntax, I will get a compiler time error: string test = "hello; <---- No closing quotation mark (Compiler-time error) Runtime errors occur after the code has been compiler and is running. If something unexpected occurs you get a runtime error: int a = 3; for(int i=0; i<10; i++){ cout << a/i << endl; <---- Divide by zero (Run-time error) }
13th Aug 2017, 6:37 PM
S C