Hey everyone, so I've been learning C++ these last couple weeks and I thought perhaps I could share what I had learned to help you out. I believe that one of the best things to do to help you learn is to teach others, so here I am! I'll keep this brief and simple, I'll also include the URL to the course on Udemy!
First things first, what is a compiler?
A compiler is used to translate your code into something your machine can understand. It inputs the source code (the code that the programmer writes) and converts it into object code (what computers understand e.g. 1110110101).
Compiler Errors
There are two types of errors; Syntax Errors and Semantic Errors. Both provide a pretty good example of what's going on with your code. These errors occur when the code you are writing is conflicting with the set of rules of a programming language.
std::cot << "Hello World" << std::endl;
return 0;
[/CODE]
std::cout << ("Hello"/10);[/CODE]
std::cout << age;[/CODE]
Want to learn C++ too? Check out the course! URL: https://www.udemy.com/beginning-c-plus-plus-programming/
First things first, what is a compiler?
A compiler is used to translate your code into something your machine can understand. It inputs the source code (the code that the programmer writes) and converts it into object code (what computers understand e.g. 1110110101).
Compiler Errors
There are two types of errors; Syntax Errors and Semantic Errors. Both provide a pretty good example of what's going on with your code. These errors occur when the code you are writing is conflicting with the set of rules of a programming language.
Syntax Errors:
A syntax error occurs when there is something wrong with the structure of the code, e.g.
[CODE lang="cpp" title="Example Syntax Error" highlight="2"]//Cout is misspeltstd::cot << "Hello World" << std::endl;
return 0;
[/CODE]
Semantic Errors
A semantic error occurs when there is something wrong calculation or logic, e.g.
[CODE lang="cpp" title="Example Semantic Error" highlight="3"]// You can not divide "Hello" because it's a string and not an integerstd::cout << ("Hello"/10);[/CODE]
Compiler WarningsA compiler warning is the compiler recognized an issue with a piece of your code that could possibly lead to a problem later on. It is very important to not ignore them but to consider them as errors. This could mean that you could be running a piece of code that you have an unused variable or a variable with no assigned value.
[CODE lang="cpp" title="Compiler Warning"]int age;std::cout << age;[/CODE]
Want to learn C++ too? Check out the course! URL: https://www.udemy.com/beginning-c-plus-plus-programming/
Last edited: