Programming/C++: Difference between revisions

From Dev Wiki
Jump to navigation Jump to search
(Brodriguez moved page C++ to C++/Syntax)
Tag: New redirect
 
(Further update page links)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
#REDIRECT [[C++/Syntax]]
 
== General C/C++ Shared Pages ==
* [[Programming/C++/Compiling Code | Compiling Code]]
* [[Programming/C++/Memory Model | Memory Model]]
 
 
== C++ SubPages ==
* [[Programming/C++/Syntax | Syntax]]
* [[Programming/C++/Pointers and Memory Management | Pointers and Memory Management]]
* [[Programming/C++/Objects and Data Structures | Objects and Data Structures]]
* [[Programming/C++/Headers and File Including | Headers and File Including]]
 
 
== Compiling C++ ==
To run any C++ code, it must first be compiled.
 
To do this, in terminal, cd to the desired directory and run {{ ic |g++ <path_to_file> -o <name_of_file_to_create>}}.
 
This will generate a new executable file, based on the compiled code.<br>
Run this file via {{ ic |./<name_of_created_file>}}.
 
 
For further details of how the compilation process works, see [[Programming/C++/Compiling Code | Compiling Code]].
 
 
== Types of Errors ==
 
* Compile Time Errors - Errors that happen during file compile.
** Syntax Errors - Errors that happen from incorrect typed syntax for the given language.
** Type Errors - Errors that happen due to mismatch of declared type and attempted type usage.
* Link Time Errors - Errors that happen when trying to combine compiled files into a single executable program.
** Ex: Using a function that was never defined, or {{ ic |Main()}} instead of {{ ic |main()}}.
* Run Time Errors - Errors that happen during program execution.
** Ex: Divide-by-zero errors, or attempting to open a file mid-runtime and said file doesn't exist.
* Logic Errors - Soft errors that don't cause an actual crash. But can cause a program soft-lock, or general unintended behavior.

Latest revision as of 19:12, 22 April 2023

General C/C++ Shared Pages


C++ SubPages


Compiling C++

To run any C++ code, it must first be compiled.

To do this, in terminal, cd to the desired directory and run g++ <path_to_file> -o <name_of_file_to_create>.

This will generate a new executable file, based on the compiled code.
Run this file via ./<name_of_created_file>.


For further details of how the compilation process works, see Compiling Code.


Types of Errors

  • Compile Time Errors - Errors that happen during file compile.
    • Syntax Errors - Errors that happen from incorrect typed syntax for the given language.
    • Type Errors - Errors that happen due to mismatch of declared type and attempted type usage.
  • Link Time Errors - Errors that happen when trying to combine compiled files into a single executable program.
    • Ex: Using a function that was never defined, or Main() instead of main().
  • Run Time Errors - Errors that happen during program execution.
    • Ex: Divide-by-zero errors, or attempting to open a file mid-runtime and said file doesn't exist.
  • Logic Errors - Soft errors that don't cause an actual crash. But can cause a program soft-lock, or general unintended behavior.