I have an assignment that requires to use class, attached is the pdf of it. I started to define the class and i am stuck at the point how to read and store in an array, usually i know how but the assignment syntax is confusing me, name[20][30]??? my main problem for now is the FileRead function.
/*--Includes\Libraries----------------------------*/
#include <iostream> //standard C++ IO operations using streams
#include <cstdlib> //standard General Purpose functions (atoi, memalloc, ...)
#include <math.h>
#include <fstream>
#include <string>
using namespace std;
//Declaration of the class
class DATA{
private: //Variables and member functions that can only be accessed by the
int scores[20]; //class.
char names[30];
int MAX;
int MIN;
int AVE;
char MAX_name[30];
char MIN_name[20];
public: //Variables and member functions that can be accessed by all Member Variables
DATA (); // constructor (make sure to initialize all numbers and chars to 0)
//Member Functions
void FileRead (char fname[25]); // function will read
void FindMAX(); //function will find MAX
void FindMIN(); // function will find the minimum
void FindAVG(); // will find the average
void ShowData(); // will show the data or print out
};
void DATA::FileRead(){
names[];
scores[];
size=0;
while (fname.peek() !=EOF){
fname>>
}
//All programs start here in main function
int main(){
DATA person;
ifstream fname("a8.txt");
system("pause"); //causes the system to pause when executing, to view print outs
//not needed in Visual C++ 2008
return 0; //return 0 to terminate the main function because its data type is int
}
note: see attachment
Attached File(s)
-
270_w09_a8.pdf (5.76K)
Number of downloads: 31 -
a8.txt (124bytes)
Number of downloads: 30

New Topic/Question
Reply




MultiQuote




|