473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

classes and function overloading

6
can any one assist in solving this program i have no idea how to add students.
Write a program that manages the students’ information (upto 50 students) and
provides the various functionalities to interact with the information. These
functionalities include:
 Add new Student: A new student is added and the user
provides the student’s data for adding new record
 Add Student and copy data from existing student. A new
student is added and the student’s data is copied from the
existing student. Existing student can be found provided
the student’s roll number. When this functionality is
performed, duplicate records for same student will exist.
 Delete Student: Asks the user to enter the student’s roll
number and deletes the student’s data. [Deletion can be
performed by making the specific student’s attributes (roll
no, name, phone number, batch)empty
 Display Student: Displays all student records.
 Find/Search a Student (Search should be preformed based on
roll number. [Bonus: Ask the user for the criteria to
search students. User may choose to search by name, by roll
number, phone number or by batch. In case of multiple
matches, all the students should be displayed. For example,
user chooses to search students by batch. In that case, all
the students’ info in the specified batch should be
displayed])
The program’s menu may look like
Press 1 to Add Student
Press 2 to Add Student and copy data from existing student
Press 3 to Delete Student
Press 4 to Display all Students
Press 5 to Find a Student
Press 6 to Exit
Define a Class for students with attributes.
int roll_no ;
char name[30];
char phone_no[15];
int batch;
Define the member functions to implement the functionalities.
 Add_Student()
 Copy_Add_Student()
 Delete_Student()
 Display_Student()
 Search_Student()
[Explore and use the string.h functions to perform the string operations, like string
copy, string compare etc]
Oct 27 '13 #1
7 1756
Nepomuk
3,112 Expert 2GB
Sure, we'll assist you; however we won't solve the task for you. What have you done so far? Where are you stuck? Show us some code and tell us what the problem is / what the problems are.
Oct 27 '13 #2
hiba
6
Expand|Select|Wrap|Line Numbers
  1. #include <cstdlib>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. class std
  6. {
  7. private:
  8.         int roll_no ;
  9.         char name[30];
  10.         char phone_no[15];
  11.         int batch;
  12. public:
  13.            void initiliaze();
  14.            void Delete_Student();
  15.            void Display_Student();
  16.            void get_Student();
  17.  
  18. };
  19. void std::initiliaze()
  20. {
  21.              roll_no=0;
  22.              char name=0;
  23.              char phone_no;
  24.              int batch=0;
  25.  
  26. }
  27.  
  28. void std::get_Student()
  29. {
  30.     cout<<"Enter the student name == "<<endl;
  31.     int i=0;
  32.     for(int i=0;i<=5;i++)
  33.     cin>>name[30];
  34.  
  35.  
  36.     cout<<"Enter the phone nu == "<<endl;
  37.     int j=0;
  38.     for(int j=0;j<=5;j++)
  39.     cin>>phone_no[15];
  40. }
  41.  
  42.  
  43. void std::Display_Student()
  44. {
  45.         cout<<"student name";
  46.         cout<<"\n"<<name[30];
  47.         cout<<"\n"<<phone_no[15];
  48.  
  49. }
  50. void std:: Delete_Student()
  51. {
  52.     int del;
  53.     cout<<"Enter the name you want to remove == ";
  54.     cin>>del;
  55.     for(int search=0; search<name; search++)
  56.     {
  57.         if(del == name[search])
  58.         {   roll_no[search]=0;
  59.             phone_no[search]=0;
  60.             batch no[search]=0;
  61.         }
  62.     }
  63. }
  64. int main()
  65. {
  66.     student detail;
  67.  
  68.     detail.initiliaze();
  69.     int x;
  70.     do
  71.     {
  72.         cout<<"\n\nYou have the following option";
  73.         cout<<"\n\nPress 1 for geting values";
  74.         cout<<"\n\nPress 3 for DELETE AN ITEM";
  75.         cout<<"\n\nPress 4 for DISPLAY ALL ITEMS";
  76.         cout<<"\n\nPress 5 for QUIT";
  77.  
  78.         cout<<"\nEnter The Desired Number == \n";
  79.         cin>>x;
  80.         switch(x)
  81.         {
  82.         case 1:
  83.             {
  84.                 detail.get_item();
  85.                 break;
  86.             }
  87.  
  88.         case 3:
  89.             {
  90.                 detail.delete_student();
  91.                 break;
  92.             }
  93.         case 4:
  94.             {
  95.                 detail.Display_Stident();
  96.                 break;
  97.             }
  98.         case 5:
  99.             break;
  100.         default: cout<<"Incorrect option Please Press the right number == ";
  101.         }
  102.  
  103.     }while(x!=5);
  104.  
  105.     getchar();
  106.     return 0;
  107. }
  108.  
  109.  
  110.  
i am finding errors in main funcction.
Oct 27 '13 #3
hiba
6
tell me i have problems in main function how to remove them
Oct 27 '13 #4
Nepomuk
3,112 Expert 2GB
First tell us: Which errors are you finding? Are you finding them at compilation or runtime?
Oct 27 '13 #5
hiba
6
yes i am facing errors at compilation
Oct 27 '13 #6
hiba
6
can any one edit it and make it in running form?
Oct 27 '13 #7
weaknessforcats
9,208 Expert Mod 8TB
The first thing is to not name your class std. The is a namespace std that is used by the C++ library functions.

Also, you call Display_Stident() in main() and there is no such method in your class. I expect you meant Display_Student().
Oct 27 '13 #8

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

Similar topics

11
by: iceColdFire | last post by:
Hi, What is the Diff btwn Function overloading and overriding thanks, a.a.cpp
16
by: WittyGuy | last post by:
Hi, What is the major difference between function overloading and function templates? Thanks! http://www.gotw.ca/resources/clcm.htm for info about ]
3
by: Iyer, Prasad C | last post by:
I am new to python. I have few questions a. Is there something like function overloading in python? b. Can I overload __init__ method Thanks in advance regards
39
by: zeus | last post by:
I know function overloading is not supported in C. I have a few questions about this: 1. Why? is it from technical reasons? if so, which? 2. why wasn't it introduced to the ANSI? 3. Is there any...
45
by: JaSeong Ju | last post by:
I would like to overload a C function. Is there any easy way to do this?
6
by: flopbucket | last post by:
Could someone explain to me what the difference is between function template specialization and function overloading? I guess overloading can change the number of parameters, but otherwise they...
15
by: lordkain | last post by:
is it possible to do some kind of function overloading in c? and that the return type is different
10
by: Matthew | last post by:
Am I correct in thinking there is no method/function overloading of any kind in any version of PHP? Thanks, Matthew
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.