General basic knowledge !important
Datatypes C++
While writing program in any language, you need to use various variables to store various information.
Variables are nothing but reserved memory locations to store values.
This means that when you create a variable you reserve some space in memory.
You may like to store information of various data types like character,
wide character, integer, floating point, double floating point, boolean etc.
Based on the data type of a variable, the operating system allocates
memory and decides what can be stored in the reserved memory.
Primitive Built-in Types
C++ offers the programmer a rich assortment of built-in as well as user defined data types.
Following table lists down seven basic C++ data types −
Several of the basic types can be modified using one or more of these type modifiers −
♣ signed
♦ unsigned
♠ short
♥ long
The following table shows the variable type, how much memory it takes to store the value in memory,
and what is maximum and minimum value which can be stored in such type of variables.
The size of variables might be different from those shown in the above table,
depending on the compiler and the computer you are using.
source: https://www.tutorialspoint.com/cplus...data_types.htm
Functions
General
Usage:
⦁ For structuring the programm → it gets clearer
⦁ outsourcing of common used Codeparts
⦁ Summarizing in libraries(e.g. in systemlibraries(~using namespace stdr;))
Functions contain stand-alone code, which is executed only when the functions are used (= called).
Function types
It exists 4 different function types:
⦁ Without return_value and without handover parameters
⦁ With return_value, but without handover parameters
⦁ Without return_value, but with handover parameters
⦁ With return_value and with handover parameters
Function without return_value and without handover parameters
general syntax:
void functionname(void)
{
⁞
instruction(s)
⁞
}
Prototype specification:
void functionname(void);
call:
functionname();
Function with return_value, but without handover parameters
general syntax:
datatype fuctionname(void)
{
⁞
instruction(s)
⁞
return variable/value;
}
Prototype specification:
datatype functionname(void);
Call:
Variable = functionname();
Function without return_value, but with handover parameters
General Syntax:
void functionname(datatype variable1, datatype variable2, ….., datatype VariableX)
{
⁞
instruction(s)
⁞
}
Prototype specification:
void functionname(Datatype variable1, datatype variable2, ….., datatype variableX);
Call:
functionname(VariableA, variableB, ….., variableX)
Functions with return_value and with handover parameters
General syntax:
datatype functionname(datatype variable1, datatype variable2, ….., datatype variableX)
{
⁞
instruction(s)
⁞
return variable/value;
}
Prototype specifications:
datatype functionname(datatype variable1, datatype variable2, ….., datatype variableX);
Call:
functionname(variableA, variableB, ….., variableX)
-----
@Lost: Cancle me as Teacher! I'll be leavin this game, but dont wanted to do it without doing anything, so here you have something you always can look at if you should forget which is used how etc.
Last edited by BlueEvil; Oct 29, 2017 at 11:32 AM.
Reason: <24 hour edit/bump