Language: C++

#include <stdio.h>
#include <iostream>
#include <cstdlib>
using namespace std;

typedef struct {
	char name[11] = "\0";
	int time;
} P;

class Queue {
private:
	int size;
	P *queue;
	int head = 0;
	int tail = 0;
public:
	Queue::Queue(int n);
	void Queue::enqueue(P p);
	void Queue::dequeue();
	bool Queue::isEmpty();
	*P Queue::get();
	void Queue::clear()
}

Queue::Queue(int n)
{
	size = n;
	queue = new P[n];
}

void Queue::enqueue(P p)
{
	queue[tail] = p;
	tail = (tail + 1) % size;
}

void Queue::dequeue()
{
	head = (head + 1) % size;
}

bool Queue::isEmpty()
{
	return head == tail;
}

*P Queue::get()
{
	return &queue[head];
}

void Queue::clear()
{
	delete[] queue;
}

int main(void)
{	
	int n, q;
	cin >> n >> q;
	
	Queue queue(n);
	for (int i = 0; i < n; i++) {
		P p;
		cin >> p.name;
		cin >> p.time;
		queue.enqueue(p);
	}
	
	int time = 0;
	while (!queue.isEmpty()) {
		P *p = queue.get();
		if (p->time <= q) {
			time += p->time;
			queue.dequeue();
			cout << p->name << " ";
			cout << time << endl;
		} else {
			time += q;
			p->time -= q;
			queue.dequeue();
			queue.enqueue(p);
		}
	}
	
	queue.clear();
	return 0;
}

Compiler output:
a.cc:18:9: error: extra qualification 'Queue::' on member 'Queue' [-fpermissive]
   18 |         Queue::Queue(int n);
      |         ^~~~~
a.cc:19:14: error: extra qualification 'Queue::' on member 'enqueue' [-fpermissive]
   19 |         void Queue::enqueue(P p);
      |              ^~~~~
a.cc:20:14: error: extra qualification 'Queue::' on member 'dequeue' [-fpermissive]
   20 |         void Queue::dequeue();
      |              ^~~~~
a.cc:21:14: error: extra qualification 'Queue::' on member 'isEmpty' [-fpermissive]
   21 |         bool Queue::isEmpty();
      |              ^~~~~
a.cc:22:10: error: ISO C++ forbids declaration of 'P' with no type [-fpermissive]
   22 |         *P Queue::get();
      |          ^
a.cc:22:10: error: expected ';' at end of member declaration
   22 |         *P Queue::get();
      |          ^
      |           ;
a.cc:22:10: error: declaration of 'int* Queue::P' changes meaning of 'P' [-Wchanges-meaning]
a.cc:14:9: note: used here to mean 'typedef struct P P'
   14 |         P *queue;
      |         ^
a.cc:9:3: note: declared here
    9 | } P;
      |   ^
a.cc:22:12: error: ISO C++ forbids declaration of 'get' with no type [-fpermissive]
   22 |         *P Queue::get();
      |            ^~~~~
a.cc:22:12: error: extra qualification 'Queue::' on member 'get' [-fpermissive]
a.cc:23:14: error: extra qualification 'Queue::' on member 'clear' [-fpermissive]
   23 |         void Queue::clear()
      |              ^~~~~
a.cc:23:27: error: expected ';' at end of member declaration
   23 |         void Queue::clear()
      |                           ^
      |                            ;
a.cc:11:1: error: new types may not be defined in a return type
   11 | class Queue {
      | ^~~~~
a.cc:11:1: note: (perhaps a semicolon is missing after the definition of 'Queue')
a.cc:11:1: error: return type specification for constructor invalid
a.cc: In constructor 'Queue::Queue(int)':
a.cc:29:21: error: 'P' does not name a type
   29 |         queue = new P[n];
      |                     ^
a.cc: At global scope:
a.cc:32:6: error: variable or field 'enqueue' declared void
   32 | void Queue::enqueue(P p)
      |      ^~~~~
a.cc:32:23: error: expected primary-expression before 'p'
   32 | void Queue::enqueue(P p)
      |                       ^
a.cc:48:4: error: expected constructor, destructor, or type conversion before 'Queue'
   48 | *P Queue::get()
      |    ^~~~~
a.cc: In function 'int main()':
a.cc:73:33: error: invalid conversion from 'int' to 'P*' [-fpermissive]
   73 |                 P *p = queue.get();
      |                        ~~~~~~~~~^~
      |                                 |
      |                                 int
a.cc:83:39: error: cannot convert 'P*' to 'P'
   83 |                         queue.enqueue(p);
      |                                       ^
      |                                       |
      |                                       P*
a.cc:19:31: note:   initializing argument 1 of 'void Queue::enqueue(P)'
   19 |         void Queue::enqueue(P p);
      |                             ~~^