Question: Why am I getting these errors? program must be completed in visual studio 2012 as a windos CLR Forms application Code: #include #include using namespace
Why am I getting these errors? program must be completed in visual studio 2012 as a windos CLR Forms application
Code:
#include
#include
using namespace std;
class node /ode for all the members
{
public: //member declaration
int prodid;
char prodes[15];
int mfgid;
double price;
double markupper;
int qty;
node *next;
public:
node() //constructor to initialise the members
{
prodid=0;
mfgid=0;
price=0;
markupper=0;
qty=0;
next=NULL;
}
}; //close class node
class Slist //create single linked list class
{
node *product,*last; //declare the global varibles
public:
Slist() //initialize the global varibales with NULL
{
product=last=NULL;
}
~Slist(); //destructor
void create(); //method declaration
void count(); //count number of nodes
void sort(); //sort the linked list
void retailprice();
void display(); // display the list
void setValues(int id,char *des,int mfd,double pr,double mark,int qt); //set the members with this functions
};
void Slist::setValues(int id,char *des,int mfd,double pr,double mark,int qt)
{
node *temp;
temp = new node; //memory allocationfor node
temp->prodid=id;
strcpy_s(temp->prodes,des);
temp->mfgid=mfd;
temp->price=pr;
temp->markupper=mark;
temp->qty=qt;
temp->next=NULL;
if (product==NULL) //check for first node
{
product=last=temp;
}
else //if not first node
{
last->next=temp;
last=temp;
}
}
void Slist ::count() //count number of nodes
{
node *temp;
int c=0;
temp=product;
while(temp!=NULL) //repeat the loop until end of the list
{
c++;
temp=temp->next;
}
cout
}
Slist ::~Slist() //definationof destructor
{
node *temp;
temp=product;
while(temp)
{
product=temp->next;
delete temp;
temp=product;
}
}
void Slist::create() //create the list
{
node *temp;
int id;
while (1)
{
cout
cin>>id;
if(id==0)
break;
temp = new node;
temp->prodid=id;
cout
cin>>temp->prodes;
cout
cin>>temp->mfgid;
cout
cin>>temp->price;
cout
cin>>temp->markupper;
cout
cin>>temp->qty;
temp->next=NULL;
if (product==NULL)
{
product=last=temp;
}
else
{
last->next=temp;
last=temp;
}
}
cout
}
void Slist::sort() //sort the list
{
node *temp1,*temp2;int temp;
double t;
char str[15];
for(temp1=product;temp1!=NULL;temp1=temp1->next)
for(temp2=temp1->next;temp2!=NULL;temp2=temp2->next)
if(temp1->prodid > temp2->prodid)
{
//swap the contents
temp=temp1->prodid;
temp1->prodid=temp2->prodid;
temp2->prodid=temp;
temp=temp1->mfgid;
temp1->mfgid=temp2->mfgid;
temp2->mfgid=temp;
strcpy_s(str,temp1->prodes);
strcpy_s(temp1->prodes,temp2->prodes);
strcpy_s(temp2->prodes,str);
t=temp1->price;
temp1->price=temp2->price;
temp2->price=t;
t=temp1->markupper;
temp1->markupper=temp2->markupper;
temp2->markupper=t;
temp=temp1->qty;
temp1->qty=temp2->qty;
temp2->qty=temp;
/*
this is also correct but some compilers are not support
*temp=*temp1;
*temp1=*temp2;
*temp2=*temp;*/
}
}
void Slist::display() //display the content
{
node *temp;
temp=product;
cout
while(temp!=NULL)
{
coutprodid;
coutprodes;
coutmfgid;
coutprice;
coutmarkupper
coutqty;
temp=temp->next;
}
}
int main() //main program
{
Slist sl;
int ch,id,mfd,qt;
double pr,mark;
char des[15];
do
{
cout
cout
cout
cin>>ch;
//select your required option
switch(ch)
{
case 1:
sl.create(); //call the create method
break;
case 2:
sl.sort(); //call the sort method
break;
case 3:
sl.count(); //call count method
break;
case 4: //input the member values and pass to setvalues
cout
cin>>id;
cout
cin>>des;
cout
cin>>mfd;
cout
cin>>pr;
cout
cin>>mark;
cout
cin>>qt;
sl.setValues(id,des,mfd,pr,mark,qt);
break;
case 5://display the data
sl.display();
break;
default:
cout
}
}while(ch!=5);//conditon to repeat the menu
}//end of the program

rror List . | * 7 Errors | ? 3 warrings | 0 0 Messages 1 waming LNK4022 cannot ind unique match for symbol'main 3 waming LNK4002 nt_crcal main void)manM Search Error List Program4 Program Program4 Program4 Program4 Program4 Program4 Program4 Program4 Program4 defined in defined in Debug Source.obj 4 error LNK1152: cannot resolve one or more undecorated symbo's 21 5 ntelSense: a function type involving a generic parameter cannot heve an elipsis parameter 6 IntelSense: a function type involving a generic parameter cannot heve an elipsis parameter 7ntelSense: Inkage specification is incompatble with previous bsearch s"(dedared at ine 426) 8 IntelSense: inkage specification is incompatble with previous bsearch(dedared at ine 430) 9 IntelSense: Inkage specification is incompatble with previous qort s"(dedared at ine 43S) 10 IntelSense: inkage specification is incompatble with previous qort (dedered at line 439) 82 567 570 574 578 23 stdib.h stdib.h stdib.h stdib.h 16 16
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
