Files
cpp-learnings/simpleConsole.cpp
2026-07-29 23:55:01 +03:00

69 lines
1.3 KiB
C++

// simpleConsole.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include "Player.h"
using namespace Game;
bool running = true;
struct Vector2 {
int x;
int y;
int sum() {
return x + y;
}
};
void loopIndexes() {
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 10; j++) {
std::cout << "J: " << j << std::endl;
running = false;
}
std::cout << "I: " << i << std::endl;
}
}
void heapMemory() {
int stackInt = 10;
int* heapInt = new int(10);
std::cout << "\n\n=========Heap Stuff========= \n";
std::cout << "Stack address: " << &stackInt << std::endl;
std::cout << "Heap address: " << heapInt << std::endl;
std::cout << "Pointer var's own address (also stack): " << &heapInt << std::endl;
std::cout << "============================ \n";
delete heapInt;
}
int main()
{
int health = 100;
std::cout << "Hello World!\n";
std::cout << "Health: " << health << std::endl;
Vector2 vec2 = { 5, 9 };
std::cout << vec2.x << " ";
std::cout << vec2.y << std::endl;
std::cout << vec2.sum() << std::endl;
vec2.x = 99;
std::cout << vec2.x << "\n\n Sum after change\n";
std::cout << vec2.sum() << std::endl;
Player player;
player.jump();
heapMemory();
}