can anyone help me to solve this problems??

#include<iostream>
using namespace std;


struct node
{
char ID[10];
char Position[30];
char TotalPages[10];
node *next;
};
node *head;

class cetak
{

private:
int head;
int tail;
int count;
node *kepala;
node *ekor;
public:
cetak();
bool empty();
void add(char id[], char position[], char pages[]);
void removes(char id[], char position[], char pages[]);
void displayFront();
void displayBack();
void displayall();
};

cetak::cetak()
{
head=NULL;
ekor=NULL;
count=0;
}


void cetak::add(char id[10], char position[30], char pages[10])
{
struct node *newNode;

newNode = new node;
strcpy( newNode->ID, id );
strcpy( newNode->Position, position );
strcpy( newNode->TotalPages, pages );
newNode->next = NULL;

if (newNode){
// nod baru berjaya dicipta
if (empty())
//queue kosong
kepala=newNode;
else
//queue tidak kosong
ekor->next=newNode;
ekor=newNode;
}
else
//nod baru gagal dicipta
cout<<"\nTidak dimasukkan krn ingatan tidak mencukupi\n";

}

bool cetak::empty()
{
return (count==0);
}


void cetak::displayall()
{
struct node *nodePtr = head;
if (nodePtr == NULL)
cout << "The list is empty!\n";
else
{
while (nodePtr != NULL)
{
cout << nodePtr->ID << endl;
cout << nodePtr->Position << endl;
cout << nodePtr->TotalPages << endl;
nodePtr = nodePtr->next;
}
}
}




void menu(void)
{
cout <<" Masukkan Pilihan Anda:" << endl;
cout <<" 1 > Menambah item"<< endl;
cout <<" 2 > Membuang item"<< endl;
cout <<" 3 > Memaparkan item"<< endl;
cout <<" 4 > Keluar dari sistem"<< endl;
cout <<" Pilihan Anda ====> ";
}


void main()
{
int pilih = 0;
char item1[10];
char item2[30];
char item3[10];

cetak BG;

while (pilih != 4)
{
menu();
cin >> pilih; //mendapatkan pilihan operasi
switch (pilih)
{
case 1: //Operasi masukan data

cin.ignore();
cout <<" Masukkan ID anda :";
cin.getline(item1,10);
cout<<" Masukkan jawatan anda : ";
cin.getline(item2,30);
cout<<" Berapa pages u want to cetak :";
cin.getline(item3,10);
cout<<endl<<endl<<endl;
if(item2=="profesor"|| item2=="profesor madya")
BG.add(item1, item2, item3);

break;

case 3: //Operasi papar baris gilir
BG.displayall();
break;
}
}
cout << "<<<<<<Keluar dari sistem>>>>>";

}

Error : IntelliSense: a value of type "int" cannot be used to initialize an entity of type "node *"

Last edited on
Do we must guess in which statement the error occured?!

The errorneous statement is here in bold

void cetak::displayall()
{
struct node *nodePtr = head;

You are trying to assign the integer ( head ) to the pointer. See the definition of head

class cetak
{

private:
int head;
int tail;
Last edited on
is that one i bold..
Topic archived. No new replies allowed.