473,473 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do i rectify the following errors in c++ because i am not able to look and rectif

1 New Member
The following errors are shown:
1)50:identifier 'push' cannot have a type qualifier.
2)147: declaration missing;
3)147: compound statement missing ;
4)147: compound statement missing ;

Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2. #include<conio.h>
  3. class stack
  4. {
  5. private:
  6. struct node
  7. {
  8. int data;
  9. node *next;
  10. }*p;
  11. public:
  12. stack();
  13. void create(int numtot);
  14. int push();
  15. int pop();
  16. void display();
  17. ~stack();
  18. };
  19. stack::stack()
  20. {
  21. p=NULL;
  22. }
  23. void stack::create(int numtot)
  24. {
  25. node *temp,*rtr;
  26. rtr=new node;
  27. rtr=p;
  28. int num,i;
  29. for(i=0;i<numtot;i++)
  30. {
  31. if(p==NULL)
  32. {
  33. temp=new node;
  34. temp->data=num;
  35. temp->next=NULL;
  36. p=temp;
  37. }
  38. else
  39. {
  40. while(rtr->next!=NULL)
  41. {
  42. rtr=rtr->next;
  43. }
  44. temp=new node;
  45. temp->data=num;
  46. rtr->next=temp;
  47. temp->next=NULL;
  48. }
  49. int stack::push()
  50. {
  51. int num;
  52. cin>>num;
  53. s.create(num);
  54. s.display();
  55. return 0;
  56. }
  57. int stack::pop()
  58. {
  59. node *temp,*rtr;
  60. int item;
  61. rtr=new node;
  62. rtr=p;
  63. if(rtr==NULL)
  64. cout<<"Stack is full";
  65. return NULL;
  66. else
  67. {
  68. while(rtr!=NULL)
  69. {
  70. rtr=rtr->next;
  71. }
  72. temp=new node;
  73. temp=rtr;
  74. item=temp->data;
  75. rtr=rtr->next;
  76. delete temp;
  77. return item;
  78. }
  79. }
  80. void stack::display()
  81. {
  82. int *rtr;
  83. rtr=new node;
  84. rtr=p;
  85. if(rtr==NULL)
  86. cout<<"Stack is empty";
  87. else
  88. {
  89. while(rtr->next!=NULL)
  90. {
  91. cout<<"The elements are"<<rtr->data<<"/n";
  92. rtr=rtr->next;
  93. }
  94. }
  95. }
  96. stack::~stack()
  97. {
  98. node *temp;
  99. temp=new node;
  100. while(p->next!=null)
  101. {
  102. temp=p;
  103. p=p->next;
  104. delete temp;
  105. }
  106. }
  107. int main()
  108. {
  109. stack s;
  110. int numtot,ch,a;
  111. do
  112. {
  113. cout<<"Stack using link list"<<"/n";
  114. cout<<"_____________________"<<"/n";
  115. cout<<"1.Create"<<"/n";
  116. cout<<"2.Push"<<"/n";
  117. cout<<"3.Pop"<<"/n";
  118. cout<<"4.Display"<<"/n";
  119. cout<<"5.Exit"<<"/n";
  120. cout<<"Enter your choice:"
  121. cin>>ch;
  122. switch(ch)
  123. {
  124. case 1:
  125. cout<<"/n"<<"Enter the total numbers you are going to feed:";
  126. cin>>numtot;
  127. s.create(numtot);
  128. s.display();
  129. break;
  130. case 2:
  131. s.push();
  132. break;
  133. case 3:
  134. a=s.pop();
  135. s.display();
  136. break;
  137. case 4:
  138. s.display();
  139. break;
  140. default:
  141. break;
  142. }
  143. getch();
  144. }while(ch<5)
  145. return 0;
  146. }
Nov 3 '13 #1
0 1121

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Abhishek | last post by:
Hi, I am trying to use the STL for C++ on Compaq. From what I read in the man pages and several online documentation, it is recommended that in order to use the STL on COMPAQ , I need to use the...
4
by: Sean C. | last post by:
Helpful folks, I've just migrated our test server from V7.2 -FP11 to V8.1.3, on WinNT 4.0. Everything went pretty darn smoothly, however I get the following errors when using the Control Center:...
9
by: zolli | last post by:
Hi, I've been banging my head against this for a while now. Hoping someone here can shed some light on what's going on. On including stdlib.h in a file, I'm seeing the following errors: ...
2
by: tshad | last post by:
I have a program I am trying to compile into a dll and am getting a bunch of: the following errors: error BC30469: Reference to a non-shared member requires an object reference. At first, I...
0
by: Tiraman | last post by:
Hi , i m getting the following errors under the eventlog while i m trying to run some class that i wrote. at the first i got an error about the just-in-time : access denied and i added the...
4
by: wxforecaster | last post by:
As alluded to in my post yesterday, I'm trying to compile a common C utility in Windows. It's only reference is to zlib.h, which needs zconf.h and in turn libz.a On Unix I've compiled this with...
1
by: patilanjana | last post by:
Hi, I am getting above mentioned errors. Checked msdn, read the comments but I fail to implement it. Please help. Error is regarding using the new and delete operators. Although I do write...
1
by: abrown07 | last post by:
#include <stdio.h> int main(void) { double percent,dollars,periods,Future Future value of investment = dollars(1+percent)pow(periods) printf("Interest rate per period: ");
2
by: visesh | last post by:
This program is to be compiled and executed in Turbo c++
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.