What is error in this code? It is missing one node

#include
using namespace std;
class node{
public:
node next;
int data;
node(int d){
next = NULL;
data=d;
}
};
void print(node
&head){
node* temp= head;
while(temp->next!=NULL){
temp=temp->next;
cout<data<<" ";
}
}
void appendbyk(node*&head,int n,int k){
node *P = head;
node *C = head;
node *H = head;
node *temp = head;
int jumps = 1;
while(jumps<n-k){
temp=temp->next;
C=C->next;
jumps++;
}
C=C->next;
head=C;
while(P->next!=NULL){
P=P->next;
}
P->next = H;
// temp->next = NULL;
print(head);
}

void insertAtTail(node*&head,int data){
if(head == NULL)
{
head = new node(data);
return ;
}
node* temp = head;
while(temp->next!=NULL){
temp=temp->next;
}
temp->next = new node(data);
return;
}
void buildList(node*&head,int n){
node temp = head;
int data =0;
while(n>0){
cin>>data;
insertAtTail(head,data);
n–;
}
}
int main() {
node
head=NULL;
int n,k;
cin>>n;
buildList(head,n);
cin>>k;
appendbyk(head,n,k);
return 0;
}

Hi,

You should have a pointer *next in structure rather than creating object.Also, you should have pointer head int print function.Now, Try to find some more errors on your own.

https://ide.codingblocks.com/s/186052
Still giving the same output

There was some mistake in print function. I have corrected that.