Docsity

C++ Program for Managing Music Records, Exercises of Object Oriented Programming

Toggle sidebar
bg1
#include<iostream>
#include<conio.h>
using namespace std;
struct date//date structure
{
int day;
int month;
int year;
};
struct record//structure of record
{
private:
char Singer_Name[50];
char Music_Genre[50];
char Record_Name[50];
date Release_Date;
int songs;
public://all above information is accessable by pointers
char* singer_ptr()
{
char* siptr=Singer_Name;//pointer to singer
return siptr;
}
char* mgenre_ptr()//pointer to genre
{
char* mptr=Music_Genre;
return mptr;
}
char* record_ptr()
{
char* rcptr=Record_Name;//pointer to record
return rcptr;
}
int* rdate_ptr()
{
int* rdptr=&(Release_Date.day);//pointer to date day
return rdptr;
}
int* rmonth_ptr()
{
int* rmptr=&(Release_Date.month);//pointer to date month
return rmptr;
}
int* ryear_ptr()
{
int* ryptr=&(Release_Date.year);//pointer to date year
return ryptr;
}
int* song_ptr()
{
int* soptr=&songs;//pointer to no of songs
return soptr;
docsity.com
pf3
pf4

Partial preview of the text

Download C++ Program for Managing Music Records and more Exercises Object Oriented Programming in PDF only on Docsity!

#include #include<conio.h> using namespace std; struct date//date structure { int day; int month; int year; }; struct record//structure of record { private: char Singer_Name[50]; char Music_Genre[50]; char Record_Name[50]; date Release_Date; int songs; public://all above information is accessable by pointers

char* singer_ptr() { char* siptr=Singer_Name;//pointer to singer return siptr; } char* mgenre_ptr()//pointer to genre { char* mptr=Music_Genre; return mptr; } char* record_ptr() { char* rcptr=Record_Name;//pointer to record return rcptr; } int* rdate_ptr() { int* rdptr=&(Release_Date.day);//pointer to date day return rdptr; } int* rmonth_ptr() { int* rmptr=&(Release_Date.month);//pointer to date month return rmptr; } int* ryear_ptr() { int* ryptr=&(Release_Date.year);//pointer to date year return ryptr; } int* song_ptr() { int* soptr=&songs;//pointer to no of songs return soptr;

void main() { int i,j,k,l=0; record music_col[100]; cout<<"how many records you want to enter ?"<<endl; cin>>k; if(k<0) cout<<"wrong input"<<endl; else { for(i=0;i<k;i++) { cout<<"enter singer name of "<< i+1 <<" record(at most 50 characters)"<<'\n'; cin.sync(); cin.getline(music_col[i].singer_ptr(), 50); cout<<"enter music genre of "<< i+1 <<" record(at most 50 characters)"<<'\n'; cin.getline(music_col[i].mgenre_ptr(), 50); cout<<"enter name of "<< i+1 <<" record(at most 50 characters)"<<'\n'; cin.getline(music_col[i].record_ptr(), 50); cout<<"enter release date of "<< i+1 <<" record"<<'\n'; cin>>(music_col[i].rdate_ptr()); cout<<"enter release month of "<< i+1 <<" record"<<'\n'; cin>>(music_col[i].rmonth_ptr()); cout<<"enter release year of "<< i+1 <<" record"<<'\n'; cin>>(music_col[i].ryear_ptr()); cout<<"enter no.of songs in "<< i+1 <<" record"<<'\n'; cin>>(music_col[i].song_ptr()); } while(l!=-1) { cout<<"what next you want to do ?"<<endl<<"1-to view any record"<<endl<<"2-to add record"<<endl<<"3-to delete record"<<endl<<"4-to exit the program"<<endl; cin>>j; switch(j) { case 1: if(k!=0) { cout<<"which record you want to see?"<<endl; cin>>i; if(i>0 && i<=k) { cout<<"Singer Name: "<<music_col[i- 1].singer_ptr()<<endl; //subsript of array starts from 0 cout<<"Music Genre: "<<music_col[i- 1].mgenre_ptr()<<endl;

break; default: cout<<"wrong input"<<endl; } } } }