get nullptr'd lol

This commit is contained in:
2024-03-04 11:54:27 -06:00
parent 9bbae8730d
commit 5088bded35
26 changed files with 1540 additions and 10 deletions

View File

@@ -0,0 +1,24 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/cppFiles/file.cc to edit this template
*/
#include <iostream>
using namespace std;
#include "pointers1.h"
void dereferencePointer() {
int x = 5;
int * p = &x;
int & r = x;
// dereference pointer
cout << *p << " " << p << " " << x << " " << &x << " " << r << " " << &r << endl;
}
int * createAnIntegerOnHeap(int x) {
int * p = new int;
if (p == nullptr) {
return nullptr;
}
return p;
}