Question: In the case of CPUs, the (linux specific) sys calls `getcpu()` or `sched_getcpu()` can be used inside a program to obtain the ID of the core executing them. For example, in the case of a 4 processors system, the logical index returned by the mentionned calls makes it possible to deduce which one of the 4 CPUs is being used (let's say every CPU contains 10 cores, therefore if `sched_getcpu()` returns 20, that means the CPU #2 is being used since the core number 20 is in the 3rd CPU).

How can I achieve a similar thing in the case of GPUs? Is there a way to find which one is being used in real time from inside an application?

Answer: 
Ignoring all of the irrelevant code in the question, the problem is this:

```
class base {};
class derived : base {};

base *ptr = new derived;

```

`derived` inherits **privately** from `base`, so, as the error message says, converting that `derived*` created by `new derived` to a `base*` is not legal. The fix is simply to publicly inherit:

```
class derived : public base {};

```
You need to publicly inherit it (with `class` it default to `private`)

```
class silver : public card
{
  //...
};

```

you cannot access private base outside because, well, it's private (like private member)