The 2025 Wheel Reinvention Jam just concluded. See the results.

Pointers type vs regular type

Is there any guideline that tells when should we use pointer type and regular type in a struct(or class) definition?

For example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
struct bar
{
   int ID;
   int Handle;
   ...
};

struct foo
{
    bar *Bar; // <- Here how do we decide whether to use pointer type or just regular type i.e bar Bar;  
};

Edited by skye_r on Reason: Initial post
If you need to store data itself or a copy, then you put a value type. If you need to reference the data that is stored in some other place - you use pointer. That's the whole point of pointers - to point to data in some other place.

Edited by Mārtiņš Možeiko on
Second link has bad information and very incorrect code examples - it is doing totally different things than claimed.