473,583 Members | 3,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use delete in string in c++ With using class (delete information)

2 New Member
Hi, friends:

This is my programme (work on Microsoft visual c++) and I have two question .

First, I want to say that there is no error but I need a little help.

This is a small programme about Bank :


it's work but my question is (about 6-closing account) on function closing account....
.....How could I delete the information in this function to close account by using string (I know how to delete in pointer,but
here I don't use pointer ,I want to use string) should I make it zero's (but I don't think so )
...I really need a help........

Please Help




and I have another question but not importante like the first one , that if I want to use two class in the
programme not one class , I'll make it class Bank (which have making new account & closing account & Zakat account) and the
other class is class account (which have the deposit & the withdrawal & the display of information for just one account)


Expand|Select|Wrap|Line Numbers
  1.  #include <iostream> 
  2. #include <string> //Must include this to use class string 
  3.  
  4. using namespace std; 
  5. class account 
  6. private: 
  7. //int size; 
  8. //int customer; 
  9. string firstname,lastname,name; 
  10. double accountbalance,amount1,amount2; 
  11. int index; 
  12.  
  13. double zakat1,zakat; 
  14. int num,i,month; 
  15. /*static*/ int counter; 
  16.  
  17.  
  18. public: 
  19.  
  20. account(){index=1;counter=0;cout<<"account constructor\n";} 
  21. void newaccount(); 
  22. void closeaccount(); 
  23. void calzakat(); 
  24. ~account(){cout<<"account destrurctor\n";} 
  25. void depositing(); 
  26. void withdrawal(); 
  27. void displayaccount(); 
  28. }; 
  29. //static int bank::counter=0; 
  30. void account::newaccount() 
  31. cout<<"enter the customer firstname,lastname,account balance\n"; 
  32. //customer=index; 
  33. cin>>firstname; 
  34. cin>>lastname; 
  35. name=firstname+lastname; 
  36. cin>>accountbalance; 
  37. index++; 
  38. counter++; 
  39. void account::closeaccount() 
  40. //name=' '; 
  41. accountbalance=00.00; 
  42. counter--; 
  43. /* 
  44. for(int y=0;y<index;y++) 
  45. if((y==num)||(y>num)) 
  46. customer[y]=customer[y+1]; 
  47. name[y]=name[y+1]; 
  48. accountbalance[y]=accountbalance[y+1]; 
  49. customer[size-1]; 
  50. name[size-1]; 
  51. accountbalance[size-1];*/ 
  52. void account::calzakat() 
  53. cout<<"enter how many month is ago from last deposite money in the account th to calculate zakat\n"; 
  54. cin>>month; 
  55. if((accountbalance>4000)&&(month>12)) 
  56. zakat1=((accountbalance*2.5)/100); 
  57. accountbalance=accountbalance-zakat1; 
  58. cout<<" the name of the customer "<<name; 
  59. cout<<" the account balance "<<accountbalance<<"\n"<<"the zakat is\n"<<zakat1<<"\n"; 
  60. else 
  61. zakat1=00.00; 
  62. cout<<" the name of the customer "<<name; 
  63. cout<<" the account balance "<<accountbalance<<"\n"<<zakat1<<"\n"; 
  64. zakat=zakat+zakat1; 
  65.  
  66.  
  67.  
  68.  
  69.  
  70. void account::depositing() 
  71. cout<<"enter the amount you want to depositing\n"; 
  72. cin>>amount1; 
  73. accountbalance=accountbalance+amount1; 
  74. cout<<"the account balance after the depositing\n"<<accountbalance; 
  75. void account::withdrawal() 
  76.  
  77. cout<<"enter the amount you want to withdrawal\n"; 
  78. cin>>amount2; 
  79. if (amount2<=accountbalance) 
  80. accountbalance=accountbalance-amount2; 
  81. cout<<"the account balance after withdrawal from it\n"; 
  82. cout<<accountbalance; 
  83. else 
  84. cout<<"sorry..the account is less than the amount you want to withdrawal\n"; 
  85.  
  86.  
  87. void account::displayaccount() 
  88. cout<<"the name of customer is\n"<<name<<"\nthe account balance is\n"<<accountbalance<<"\n"; 
  89.  
  90.  
  91. int main() 
  92. int choice,accountnum,x; 
  93. account ob[3]; 
  94.  
  95. do 
  96. cout<<"enter your choice\n"; 
  97. cout<<"1-Opening a new account for a customer\n"; 
  98. cout<<"2-deposit to the account\n"; 
  99. cout<<"3-withdrawal from the account\n"; 
  100. cout<<"4-Zakat calculate and debits the account zakat\n"; 
  101. cout<<"5-display the information of account\n"; 
  102. cout<<"6-closing an account\n"; 
  103. cout<<"7-display all account information\n"; 
  104. cout<<"8-exit\n"; 
  105. cin>>choice; 
  106. switch(choice) 
  107. case 1: 
  108.  
  109. cout<<"enter the account number from 0 to 14\n"; 
  110. cin>>accountnum; 
  111. x=accountnum; 
  112. cout<<"the account has the number "<<x; 
  113. ob[accountnum].newaccount(); 
  114. break; 
  115. case 2: 
  116. cout<<"enter the account number from 0 to 14 to depositing it\n"; 
  117. cin>>accountnum; 
  118. x=accountnum; 
  119. cout<<"the account has the number "<<x; 
  120. ob[accountnum].depositing(); 
  121. break; 
  122. case 3: 
  123. cout<<"enter the account number from 0 to 14 to withdrawal from it\n"; 
  124. cin>>accountnum; 
  125. x=accountnum; 
  126. cout<<"the account has the number "<<x; 
  127. ob[accountnum].withdrawal(); 
  128. break; 
  129. case 4: 
  130. cout<<"enter the account number from 0 to 14 to calculate zakat to it\n"; 
  131. cin>>accountnum; 
  132. x=accountnum; 
  133. cout<<"the account has the number "<<x; 
  134. ob[accountnum].calzakat(); 
  135. break; 
  136. case 5: 
  137. cout<<"enter the account number from 0 to 14 to display it\n"; 
  138. cin>>accountnum; 
  139. x=accountnum; 
  140. cout<<" the account that has the number "<<x; 
  141. ob[accountnum].displayaccount(); 
  142. break; 
  143. case 6: 
  144. cout<<"enter the account number from 0 to 14 to close it\n"; 
  145. cin>>accountnum; 
  146. x=accountnum; 
  147. cout<<"the account has the number "<<x; 
  148. ob[accountnum].closeaccount(); 
  149. break; 
  150. case 7: 
  151. int i; 
  152. for(i=0;i<3;i++) 
  153. cout<<"the zakat of the account that has the number "<<i; 
  154. ob[i].displayaccount(); 
  155. break; 
  156. case 8: 
  157. cout<<"the exit\n"; 
  158. break; 
  159. default: 
  160. cout<<"invalid choice\n"; 
  161. break; 
  162. }//end switch 
  163. }//end while 
  164. while(choice!=8); 
  165. return 0; 
  166.  
Thank you all very much..........I hope if any one can help me ..
..........I need it tomorrow .... :o
Nov 20 '05 #1
2 10211
memosa
2 New Member
thanks i solved it with flag
Nov 22 '05 #2
phantomboy
1 New Member
memosa is there any chance to post your solution...
I have th same problem and i have to give my work yesterday...

The code works in the same way in c++??
Feb 10 '06 #3

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

Similar topics

1
3836
by: Nimmi Srivastav | last post by:
There's a rather nondescript book called "Using Borland C++" by Lee and Mark Atkinson (Que Corporation) which presents an excellent discussion of overloaded new and delete operators. In fact there are quite a few things that I learned that I did not know before. For example, while I knew that the new and delete operators can be overloaded...
4
1558
by: Eric A. Johnson | last post by:
Hi, I am working on a way to create a "window" within a dos console. I'm using Microsoft Visual C++. My main problem is that I am using new to create a new CHAR_INFO array within the constructor, and I want to destroy it within the destructor using delete. However, the array is not known outside of the constructor. This is a class...
0
1254
by: Kevin | last post by:
I am successfully creating and deleting appointments and sending invitations in a C# / ASP.NET / Exchange2000 environment. It works great! But the problem is that no notifications are sent out when I programmatically delete or modify appointments. This is a key feature that we will need and I am looking for information/documentation on...
0
1494
by: laurent | last post by:
Environment: VS NET 2003 Fr Framework: 1.1 OS: WinXP SP2 Fr Hello I have a problem to add with pop-up and to delete in a datagrid(ButtonColumn delete) on WebForms. code button HTML which opens pop-up: <INPUT class="buttonForm"...
3
4641
by: silver360 | last post by:
Hello, I'm trying to create a basic Heap manager and i have some question about new/delete overloading. The following code give me this output : >> $./heap >> registered : 0x804d098 >> 0x804d008 _Delete unknown block >> registered : 0x804d138 >> 0x804d008 _Delete unknown block >> 0x804d098 _Delete ok
6
3846
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called "Generations"), and it allows the user to add, edit and delete the various records of the table. "Generations" table has the following fields: "IDPerson",...
2
1436
by: rohits123 | last post by:
To optimize the memory usage , I am using a huge block of memory for my system and then dividing the initial chunk in to 4 pools. I have overloaded new and delete such that memory from a particular pool can be taken and freed . As far as possible memory can be taken from particular pool and memory is freed (comlete pool as whole ) when...
7
6924
by: ITAutobot25 | last post by:
My delete button is not working in my GUI and my due date is today before midnight. Can anyone show me how to correct this error? My assignment statement is below as well as 5 classes. InventoryGUI is the main class to begin execution. Thanks! • Modify the Inventory Program to include an Add button, a Delete button, and a Modify button on the...
13
26907
by: ramprakashjava | last post by:
hi, i hav "java.lang.NullPointerException" error while Deleting table records using checkbox in jsp here i enclosed files help quickly plzzz.. Regards Ramprakash ...
0
7894
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8321
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8191
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5699
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5370
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3841
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1426
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1154
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.