Skip to main content

Questions tagged [pointers]

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

1vote
1answer
576views

Tagged pointers vs. fat pointers

I'm writing my own dynamic programming language. So far I've been using a tagged union for all values. Since this boxes primitive types needlessly, I've begun researching tagged pointers which seem to ...
Matheus Moreira's user avatar
1vote
7answers
391views

Is it possible to introduce Pointers to a weakly typed programming language?

Most weakly typed languages do not have a concept of a pointer. Instead, most of them use references. However, is it possible to introduce pointers to such a language. From a naive point of view, to ...
Lily White's user avatar
1vote
4answers
748views

Passing arrays as global variables instead of pointers in C

I'm required to write the Low-Level Requirements of a Software Component which shall perform signal processing over arrays of 200k elements of integers/floats which lives in the main memory of the ...
Sam's user avatar
  • 31
0votes
1answer
79views

Avoiding repeating code when assigning pointer addresses based on branch

I have the following code in C that reads data off a char array and makes decisions on what variables should some pointers point to. char preset1[20]; char preset1Name[20]; int preset1Temp; int ...
HFOrangefish's user avatar
0votes
1answer
111views

Is it safe to make training data and labels as global variables in C?

I'm trying to make this function called walk in C. The idea is that the function takes as parameters a point in space (represented by an array), a function (pointer), and a step size / learning rate ...
Mehdi Charife's user avatar
4votes
2answers
2kviews

Reference variable vs Alias

When I started programming, I learned what Pointers are in C++. In Java, references are variables which hold the address of an object. So conceptually it's a pointer, without the ability to directly ...
tweekz's user avatar
7votes
1answer
201views

What is the term used to describe the number of times a pointer can be dereferenced?

For example, which term completes the sentence "p has 5 ____" in order to describe a situation like int *****p?
vim_overlord's user avatar
0votes
1answer
401views

Implement Dependency Inversion in C with UML diagram

As per Robert C. Martin in Clean Architecture, he gives a simple UML diagram to illustrate Dependency Inversion. To put it simply, HL1 initially referred to ML1 without interface to invoke F() ...
Andy Lin's user avatar
-1votes
5answers
2kviews

In C++, does dereferencing a nullptr itself cause undefined behaviour, or is it the acting upon the dereferenced pointer which is undefined?

I happen to have a reason why I might want to dereference a nullptr. Of course when I do, my program crashes, and from what I gather, this is due to the compiler playing it safe and stopping my ...
Anon's user avatar
  • 3,633
1vote
4answers
11kviews

C++: Is a pointer to a vector going to cause memory issues?

I started to write a function which had a pointer to a vector as a parameter so that it could modify that vector to output results (as the actual return value was an error code), when I started to ...
I_like_robots's user avatar
2votes
2answers
299views

Can you define node pointers in a base binary tree class?

I've created two separate binary tree classes, with some shared functions/variables and some that are not shared. So I have tried to abstract away the similarities in a base BinaryTree class. class ...
yomag1234's user avatar
0votes
1answer
122views

What design pattern (if so) did I apply? How can I further improve it?

Suppose I have a program.c that needs element_123 to do some operations, and element_123 can be accessed by including agent.h /*program.c*/ #include "agent.h" uint32_t element_123 = 0; ...
Andy Lin's user avatar
2votes
1answer
2kviews

How to store a vector of smart pointers, except some of them are owned by another object?

I'm making a basic platformer game. I have a Game class as well as Level class. The game object holds a pointer to the current Level object. A level currently has a std::vector of GameObject raw ...
Luke B's user avatar
11votes
3answers
3kviews

What are the pros and cons of using a reference/pointer vs an ID

I'm writing in C++, but this problem applies to any language without GC and even to languages with a GC as well. I have a structure in memory in which I create/add objects. The structure takes ...
Helloer's user avatar
65votes
10answers
21kviews

I never use pointers in my C++ code. Am I coding C++ wrong? [closed]

This question may sound strange to you, but I am learning C++ all by myself. I have nobody whom I could ask for mentoring and I would be very glad for some advice. I have started recently to program ...
curiouscupcake's user avatar

153050per page
close