65 lines
1.5 KiB
C++

#include <iostream>
/*
struct Node {
int el;
Node* ptrNext;
};
//void insertAtBeginning(Node* start, int n) {
void insertAtBeginning(Node*& start, int n) {
Node* ptrTemp = new Node;
ptrTemp->el = n;
ptrTemp->ptrNext = start;
start=ptrTemp;
}
//void print(Node*& start) {
void print(Node* start) {
while (start) {
std::cout << start-> el << " ";
start=start->ptrNext;
}
std::cout << std::endl;
}
*/
/*
void print(Node*& start) {
//void print(Node* start) {
Node* temp = start;
while (temp) {
std::cout << temp-> el << " ";
temp=temp->ptrNext;
}
std::cout << std::endl;
}
*/
int main() {
int a = 10;
int b = 20;
int* p_a = &a;
int** p_p_a = &p_a;
std::cout << "a " << &a << " " << a << std::endl;
std::cout << "b " << &b << " " << b << std::endl;
std::cout << "p_a " << &p_a << " " << p_a << " " << *p_a << std::endl;
std::cout << "p_p_a " << &p_p_a << " " << p_p_a << " " << *p_p_a << " " << **p_p_a << std::endl;
std::cout << "------------------------" << std::endl;
/*
//The nullptr keyword represents a null pointer value.
Node* ptrStart = nullptr;
insertAtBeginning(ptrStart, 3);
insertAtBeginning(ptrStart, 2);
insertAtBeginning(ptrStart, 1);
print(ptrStart);
print(ptrStart);
while (ptrStart) {
Node* ptrTemp = ptrStart->ptrNext;
delete ptrStart;
ptrStart=ptrTemp;
}
*/
return 0;
}