C++ BASICS
OPEN WEBSITE
REVIEW DEFAULT FILE
REMOVE USING NAMESPACE
(add std:: to the cout line)
ADD END OF LINE TO EACH LINE
ADD USING STD::ENDL AND STD::COUT
VARIABLES
MATH
SPECIAL MATH FUNCTION
SPECIAL MATH FUNCTION
int a = 21;
int c;
c = a++;
cout << “==>> a: “ << a << endl;
cout << “==>> c: “ << c << endl;
c = ++a;
cout << “==>> a: “ << a << endl;
cout << “==>> c: “ << c << endl;
FOR LOOPS
for (auto i=0; i<3; ++i)
{
cout << “value = “ << i << endl;
}
METHODS
METHODS
#include<iostream>
#include "Factorial.h“
using std::cout;
using std::endl;
int main()
{
constexpr int value = 3;
auto fact = new Factorial();
cout << "The factorial for " << value << " is " << fact->Calc(value) << endl;
return 0;
}
METHODS
#include<iostream>
#include "Factorial.h“
int Factorial::Calc(int value)
{
auto output = 1;
for (auto i=1; i<= value; ++i)
{
output *= I;
}
return output;
}
METHODS
#pragma once
class Factorial
{
Factorial() = default;
~Factorial() = default();
int Calc(int value);
};
METHODS - CONTINUED
METHODS – PASS BY VALUE
METHODS – PASS BY VALUE
METHODS – PASS BY REFERENCE
METHODS – PASS BY POINTER
METHODS – COMPARISON OF VARIABLE PASSING