add intro

This commit is contained in:
2025-02-05 16:48:25 +01:00
commit a0b1dd4c08
9 changed files with 850 additions and 0 deletions
+118
View File
@@ -0,0 +1,118 @@
#include <iostream>
#include <Windows.h>
#include <memory>
#include "functions.h"
#include "ClassA.h"
using namespace std;
void functionB() {}
void functionC();
void functionD(); // forward declaration
int main()
{
//std::cout << "Hello World!" << std::endl;
//cout << "Hallo" << endl;
////functionA(); // compiler error, function is not declared, but defined afterwards
//functionB(); // no error
////functionC(); // linker error, function is declared, but not defined
//functionD(); // no error
////functionE(); // linker error, function is defined in header and included in two different source files
//functionF(); // no error
//short s = 0;
//unsigned short us = 0;
//int i = 0;
//long l = 0;
//cout << "sizeof short: " << sizeof(s) << endl;
//cout << "sizeof int: " << sizeof(i) << endl;
//cout << "sizeof long: " << sizeof(l) << endl;
//cout << "sizeof long long: " << sizeof(long long) << endl;
//cout << "sizeof bool: " << sizeof(bool) << endl;
//BOOL b;
//int number;
//cin >> number;
//cout << "number: " << number << endl;
//char c;
//cin >> c;
//cout << "c: " << c << endl;
//string str;
//cin >> str;
//cout << "str: " << str << endl;
//char sz[128];
//cin >> sz;
//cout << "sz: " << sz << endl;
//cin >> sz;
//cout << "sz: " << sz << endl;
//int numbers[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
//cout << "print local array" << endl;
//for (size_t i = 0; i < sizeof(numbers) / sizeof(int); i++)
//{
// cout << numbers[i] << " ";
//}
//cout << endl;
//cout << "print remote array" << endl;
//printArray(numbers, size(numbers));
//int n = 1;
//changeInt(n);
//cout << "n (" << &n << "): " << n << endl;
//changeIntPointer(&n);
//cout << "n (" << &n << "): " << n << endl;
//changeIntReference(n);
//cout << "n (" << &n << "): " << n << endl;
//int* pNumber = nullptr;
//int* pNumber2 = new int;
//
//if (pNumber2 != nullptr)
//{
// delete pNumber2;
// pNumber2 = nullptr;
//}
//pNumber = new int;
//*pNumber += 10;
//pNumber = new int; // BAD - Memory Leak
//unique_ptr<int> un = make_unique<int>(0);
//*un = 100;
//
//shared_ptr<int> sn = make_shared<int>(0);
//*sn = 10;
//cout << "sn refs: " << sn.use_count() << endl;
//shared_ptr<int> sn2 = sn;
//cout << "sn refs: " << sn.use_count() << endl;
//sn.reset();
//cout << "sn refs: " << sn.use_count() << endl;
//cout << "sn2 refs: " << sn2.use_count() << endl;
//weak_ptr<int> wn = sn2;
//if (!wn.expired())
//{
// shared_ptr<int> ln = wn.lock();
// *ln = 1234;
// cout << "sn2 refs: " << sn2.use_count() << endl;
//}
//cout << "sn2 refs: " << sn2.use_count() << endl;
ClassA classA;
ClassA classA2 = classA;
return 0;
}
void functionA() {}
void functionD() {}