get nullptr'd lol
This commit is contained in:
24
Assignments/Pointers_CalebFontenot/pointers1.cpp
Normal file
24
Assignments/Pointers_CalebFontenot/pointers1.cpp
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user