Class in c++

problem in reading/storing array/ using of class

Page 1 of 1

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

#1 moe_3_moe  Icon 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

Hello,
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)



Is This A Good Question/Topic? 0
  • +

Replies To: Class in c++

#2 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 1,002
  • 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:
http://www.fredosaur...r/22twodim.html
http://www.learn-pro...pp_learn06.html

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