hello everyone.. i have no clue how to work out this problem... i'm new to c++.
i have to define a class which would update the data members of the class.
i will have to use static data variables but i dont know how to..
the question is:
TO REPRESENT BOWLERS IN A CRICKET TEAM:
data members: frst name; last name; overs bowled; no. of maiden overs; runs given nd wickes taken;
functions:
to assign initial values; to update information; to display the bowler's info;
uhh.. here's the code:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class bowler
{
char fname[10];
char lname[10];
int static ovr_bld;
int static maiden;
int static run;
int static wkt;
public:
void getdata();
static void update();
void display();
};
int bowler::ovr_bld=6;
int bowler::maiden=2;
int bowler::run=13;
int bowler::wkt=2;
void bowler::getdata()
{
cout<<"\nEnter the first name: ";gets(fname);
cout<<"\nEnter the last name: ";gets(lname);
cout<<"\nEnter the overs bowled: ";cin>>ovr_bld;
cout<<"\nEnter the no. of maiden overs: ";cin>>maiden;
cout<<"\nEnter the runs given: ";cin>>run;
cout<<"\nEnter the wickets taken: ";cin>>wkt;
}
void bowler::update()
{
cout<<ovr_bld<<"\n";
cout<<maiden<<"\n";
cout<<run<<"\n";
cout<<wkt<<"\n";
}
void bowler::display()
{
cout<<"\nThe first name is: "<<fname;
cout<<"\nThe last name is: "<<lname;
cout<<"\nThe no. of overs bowled is: "<<ovr_bld;
cout<<"\nThe runs given: "<<run;
cout<<"\nThe wickets taken: "<<wkt;
}
void main()
{
bowler obj;
obj.getdata();
bowler::update();
obj.display();
}