Stack Exchange Network

Stack Exchange network consists of 175 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.

6
votes
1answer
65 views

Smart pointer like implementations

For educational purposes I implemented standard library smart pointers like class templates. They are definitely not a full replacement for the library classes but I'd like to get some comments on the ...
8
votes
3answers
811 views

Binary Search Tree implementation using smart pointers

I have implemented below code for binary search tree implementation using shared pointer. At present, I have considered only integers. It supports insertion and deletion of values. Also, a print ...
6
votes
1answer
94 views

unique_ptr basic implementation for single objects

This is an implementation to simulate the basic functionality of unique_ptr. This doesn't provide features like custom deleter and ...
3
votes
0answers
32 views

Basic Qt5 UI with button [closed]

I have the following Qt class: mainwindow.h class MainWindow : public QWidget { Q_OBJECT QPushButton* m_button; public: explicit MainWindow(); }; mainwindow....
15
votes
2answers
963 views

C++11 smart pointer 'library'

Edit: NOTE I'm a C++ "beginner" still in undergrad trying to teach myself modern C++ (because they don't do that in uni) so I'm sure this is riddled with errors that I am unaware of. Made a subset of ...
3
votes
1answer
115 views

value_ptr<T> - a C++11 header-only, deep-copying smart pointer that preserves value semantics for polymorphic and undefined types (updated)

My previous iteration was here. I've since finalized the concept as described in the title, and would appreciate any feedback GitHub Link Introduction: ...
1
vote
1answer
82 views

Simple Object Management System

I am attempting to create a fast & robust object management system that allows adding, removing and retrieving objects from a "scene". I am trying to wrap my head around the best way to do this ...
5
votes
1answer
346 views

C++ grades calculator using pointers

I have a program to calculate grades that uses pointers and I am trying to figure out if I did it right and if there are any problems with my implementation. I'm trying to get a more firm grasp on ...
5
votes
1answer
78 views

Implementing a doubly linked list with smart pointers

I've been learning Rust for the past few days and I just passed the "Smart Pointers" chapter. To check what I've learned I've decided to implement a doubly linked list. My question is, is this ...
1
vote
1answer
201 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
2answers
120 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-...
3
votes
2answers
117 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
98 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
89 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
83 views

Linked List using templates and smart pointers

I have an implementation of Linked List with push, pop, ...
3
votes
0answers
84 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
210 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
422 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
43 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
67 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
58 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
135 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
1k views

custom smart pointer class template

Kindly provide your review comments: ...
4
votes
2answers
281 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
119 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
73 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
150 views

Consuming a picnic lunch

I have a number of related classes (Burger, Pizza, Cupcake) with a common base class ...
5
votes
1answer
511 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
327 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: ...
12
votes
3answers
386 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
78 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
216 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
100 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
334 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
578 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
416 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
414 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
511 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
141 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
107 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
649 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
268 views

Wrapping an IntPtr in a Struct for safer Interop

Consider the following C#/C interop scenario: ...
6
votes
2answers
177 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
76 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
442 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
354 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
307 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. ...