Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [pointers]

In computer science, a pointer is a programming language data type whose value refers directly to (or "points to") another value stored elsewhere in the computer memory using its address.

1
vote
1answer
32 views

C++ wrapper for GLFW window object

I'm creating a window class in C++ to provide a bit of abstraction for a GLFW window. window.h ...
0
votes
0answers
18 views

Inserting nodes to the end of a linked list by function [on hold]

I am trying to insert nodes to the end of a linked list by function. This is the insertNode function: ...
0
votes
2answers
47 views

C++ - Hash map implementation using smart pointers

I am trying a simple Hash Map implementation in c++. I have used this and this as reference. The implemented design uses a class HashEntry to manage individual key-...
1
vote
2answers
77 views

Circular / Cyclic Buffer implementation

I am learning circular / cyclic buffer using this link. Here is the code that I have written so far: ...
2
votes
0answers
81 views

Yet Another Non-Intrusive Reference Counted Smart Pointer Implementation

I needed a reference counted smart pointer for my project, and for some reason early in my project, I decided that I did not like the std::shared_ptr. I can't ...
1
vote
1answer
43 views

Queue implementation using unique_ptr

I am trying out different data structures to learn more about smart pointers. I have created a queue implementation which has push, ...
2
votes
1answer
62 views

Linked List using templates and smart pointers

I have an implementation of Linked List with push, pop, ...
2
votes
0answers
67 views

Generic stack data structure using linked list and smart pointers

I have decided to rewrite what I did here, following the suggestions to use smart pointers. I will rewrite the other data structures as well using smart pointers where appropriate. I just want to see ...
4
votes
2answers
128 views

Double Linked List Using Smart Pointers

I have decided to rewrite what I did here, following the suggestions to use smart pointers. I will rewrite the other data structures as well using smart pointers where appropriate. I just want to see ...
7
votes
5answers
398 views

Add Two Numbers given in Reverse Order from a Linked List

Updated Question Problem Description You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a ...
1
vote
1answer
42 views

Generic Single Linked List with smart pointers follow up part 3

Okay, this will most likely be the last post I make for Singe Linked List unless significant revision is needed. This post following from here. Shout out to @hoffmale for showing me the ways of the ...
2
votes
2answers
65 views

Generic Single Linked List with smart pointers follow up part 2

This is probably the last time I will post this data structure that I have been working on. I have added in an iterator and const_iterator class (although I do not use them probably where I should be)....
1
vote
2answers
57 views

Generic Vector Class using smart_pointers

I have decided to rewrite what I did here, following the suggestions to use smart pointers. I will rewrite the other data structures as well using smart pointers where appropriate. I just want to see ...
2
votes
4answers
125 views

Generic Single Linked List Using Smart Pointers Follow up

I am extending this post following from here. I made some of the changes that I could make in the previous post. Although, I have not been successful in creating iterators for my class. The reason ...
7
votes
4answers
828 views

custom smart pointer class template

Kindly provide your review comments: ...
4
votes
2answers
213 views

Doubly linked list std::unique_ptr template class implementation

Inspired by the talk of Herb Sutter in CppCon2016, I decided to make a doubly linked list using templates, smart pointers, and raw pointers (for back-pointers, having a cycle of ...
3
votes
2answers
92 views

A traits class for (compound) pointers - beyond what std::pointer_traits offers

This is a percolation of ideas which originated this SO question: Compound pointer traits class with method generalizing make_shared and make_unique? The ...
1
vote
2answers
68 views

K&R Exercise 5-15: sorting with extra options

As I'm learning to program in C, I'm making my way through K&R. The goal of the exercise is to add a option to the program so that the sorting does not depend on upper or lower-case letters. ...
10
votes
1answer
145 views

Consuming a picnic lunch

I have a number of related classes (Burger, Pizza, Cupcake) with a common base class ...
5
votes
1answer
353 views

Graceful thread shutdown with std::move [closed]

I have a thread as part of a class that access the class's data members. The class has a move constructor that moves some of the old class's data members into the new object being constructed. Before ...
3
votes
1answer
164 views

Simple packet parsing command pattern

I'm currently creating a small server back-end. My goal is to write an (efficient) packet parser in C++17 using the command pattern. The packets are given by: ...
11
votes
3answers
200 views

A moveable QScopedPointer, or a Qt and std cross-compatible unique_pointer

I'm a hobby programmer, so I've never been through a code review before (online or offline). That said, here goes: Background I use Qt extensively but have long wanted ...
1
vote
1answer
91 views

Single Linked List - simple approach

I am a student, trying to learn C++11 and data structures. I would like to ask you to to review my code. I have spent some time and analyse similar questions on Code Review and it gave me basic idea ...
3
votes
3answers
65 views

Swapping int with string using getchar() and putchar()

I wrote code that replaces integers from 0 to 3 with strings. I was only allowed to use getchar() and putchar(). If the input is ...
3
votes
1answer
145 views

Strategy design pattern in C++ using unique_ptr

1. Introduction This is for my ANN project. Each building block of ANN, neuron, has activation function which determines how to get the output given the input (see formula in on repo I linked). I ...
-3
votes
1answer
97 views

Parser function returning a pointer

Two of my colleagues suggested that I not use a C function to return a char pointer. The way to get a char pointer is to pass it to a function and let the function ...
3
votes
2answers
101 views

Copy-and-Move Concept Using Smart Pointer

I tried to implement a simple container class using the copy-and-move idiom. I am learning the changes to C++ as of C++11 and later. Is the code exception safe? I chose to use a smart pointer. Is <...
2
votes
2answers
278 views

Swap Nodes in Pairs in singly linked list

Description: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only ...
2
votes
1answer
216 views

QT - Class For Connecting to Mqtt Broker With QMqttClient

Task: Class for connecting to a mqtt broker using QMqttClient and getting notified on connect and ...
11
votes
2answers
1k views

Trie Data Structure Implementation in C++11 using Smart Pointers — follow-up

Link to my first question. I followed @JDługosz recommendations. How does it look? Do you have any further recommendations? Is it better (if possible) to replace shared_ptr with unique_ptr? How could ...
5
votes
2answers
148 views

Smart pointer that cannot be nullptr

Sometimes I need a reference counting smart pointer that should not be nullptr. For example, I want to share a very heavy object without copying. And it's more convenient to place it on the heap. So I ...
9
votes
4answers
2k views

Singly Linked List implementation C++

Linked List C++ I am new to data structures and I have to implement my own data structures for a project. I have made this working Singly Linked List data structure in C++. I would like to ask ...
1
vote
1answer
270 views

Graph Representation using smart pointers. Kosaraju's algorithm implementation

Coming from a Java background, and being fairly new to C++ as well as code review, I am trying to get accustomed to C++11/14 concepts. I have been reading Modern Effective C++ by Scott Meyers to ...
2
votes
1answer
137 views

Multi-purpose generic pointer array with optional type-checking

I've been using this data structure in my projects for a while and finally decided to clean it up a bit and publish it online, but first I'm posting it here for code review. (EDIT: It has now been ...
1
vote
1answer
79 views

Class Putting Self in std::vector

This is a small test to try and add a copy of a containing class into a vector. To me, it looks very ugly. I hate the fact I need to write a constructor based off of a pointer in order to add the ...
4
votes
3answers
422 views

Doubly Linked List Implementation [C++]

C++ noob reporting. I'm working on implementing a doubly linked list using two separate classes: one class, called node, containing your standard doubly linked list ...
4
votes
1answer
192 views

Wrapping an IntPtr in a Struct for safer Interop

Consider the following C#/C interop scenario: ...
6
votes
2answers
149 views

RAII-style single-linked list

After watching Herb Sutter describe single-linked lists in terms of unique_ptr I decided to implement my own. In particular I want to know if my move semantics are ...
2
votes
1answer
62 views

C Vigenere Encryptor

This code is tested and working properly, I'm looking for some feedback on the following functions. Pretty straight forward and simple, but if additional information is desired, ask and I will gladly ...
6
votes
2answers
441 views

Finding first recurring letter in each string of a given set

First input is the number of strings ex: 5 Second input is a set of strings ex: hello world how are you Output the letter in the string ex: 'l' in string 1 Below is my code: ...
5
votes
3answers
213 views

Custom thread-safe shared/weak pointer implementation in C++98

So I am pretty sure the CppCoreGuidelines say that you should disregard standard libraries and write your own. Not sure I remember where, probably P.13 or somewhere around there... Anyway here is my ...
1
vote
1answer
162 views

Returning containers from function - C++ [closed]

I've been trying to implement a few interfaces for processing data. And most of the time I do new of container and return a smart pointer to this container. ...
9
votes
4answers
1k views

Populating a structure

I'm solving K&R exercise 1-13: Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation ...
1
vote
0answers
190 views

C++11 CLH Lock Implementation

As a hobbyist programmer I have been reading "The Art of Multiprocessor Programming" (Herlihy, Maurice; Shavit, Nir) and converting the Java spin locks into C++ - I have enjoyed this and learned a lot....
2
votes
1answer
135 views

Wrapping the iOS triple buffering procedure in a generic swift class

In the Metal sample code and best practices guides it is advised to use a triple buffering technique to avoid access conflicts between the cpu and the gpu. The required code to do so requires ...
8
votes
2answers
4k views

Traversing an array with a pointer to the array

I was thinking about how to traverse an array without an int iterator, and I'm curious if my answer is good/bad. The first for loop simply populates each element ...
3
votes
1answer
215 views

Parsing an XML file into a linked list

I am using libxml library to parse the xml file into my code and then assign each element node to the corresponding linked list node. I think the code runs just ...
4
votes
2answers
1k views

Binary Tree in C

It takes integers from argv[] and inserts into tree, making sure to allocate memory and free that memory once the program has finished. How can I improve code quality, what are your suggestions? <...
3
votes
2answers
99 views

Find string length using pointers

I'm trying to write a function that will work out the length of two string char arrays, using pointer arithmetic. It seems to be working but I'm still getting used to pointers and addresses etc and ...
3
votes
1answer
349 views

Templated Game Resource Manager

After scanning some of the questions here about resource managers I've made some changes, and while it is much improved I still feel it's not quite up to snuff. It tried to make it work for all data ...