Class in c++

problem in reading/storing array/ using of class

Page 1 of 1

1 Replies - 874 Views - Last Post: 03 April 2009 - 07:44 PM Rate Topic: -----

#1 moe_3_moe   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 37
  • Joined: 12-March 09

Class in c++

Post icon  Posted 03 April 2009 - 07:27 PM

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.
#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(){
	 while (fname.peek() !=EOF){

//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)

Is This A Good Question/Topic? 0
  • +

Replies To: Class in c++

#2 FrozenSnake   User is offline

  • En man från Sverige!

Reputation: 123
  • View blog
  • Posts: 1,033
  • Joined: 30-July 08

Re: Class in c++

Posted 03 April 2009 - 07:44 PM

name[20][30] is a 2D array you can read about it here:

I do not want to help you too much because it's your assignment so YOU need to complete it so I hope you at least read these links and tinker some more ;)

This post has been edited by FrozenSnake: 03 April 2009 - 07:50 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1