hey guys im using vi to try and compile code for school

in main i keep getting errors in the functions READ and PRINT and they say that the variable in the function call is not within the scope.

here is my code:

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

const int NAMESIZE=11;
const int FILENAMESIZE=51;
typedef char NAME_t[NAMESIZE];
typedef int GRADE_t;
typedef char FILENAME_t[FILENAMESIZE];
typedef fstream DATAFILE_t;
typedef fstream OUTFILE_t;

class cStudent
{
        private:
                NAME_t fname;
                NAME_t lname;
                GRADE_t t1;
                GRADE_t t2;
                GRADE_t t3;
                GRADE_t t4;
                GRADE_t assigngrade;
                GRADE_t examgrade;
        public:
                cStudent();

};//end class

void READ(DATAFILE_t &DATAFILE);
void PRINT(OUTFILE_t &OUTFILE);
void Finalize(DATAFILE_t &DATAFILE, OUTFILE_t &OUTFILE);
main()
{


        cStudent tempstudent;
        cStudent::cStudent();
        READ(DATAFILE);
        PRINT(OUTFILE);
        Finalize(DATAFILE,OUTFILE);

}//end main

void READ(DATAFILE_t &DATAFILE)
{
        FILENAME_t inputfile;
        cout<<"Enter the name of the data file:"<<endl;
        cin>>inputfile;
        DATAFILE.open(inputfile,ios::in);

};

void PRINT(OUTFILE_t &OUTFILE)
{
        FILENAME_t outputfile;
        cout<<"Enter the name of the output file to be created:"<<endl;
        cin>>outputfile;
        OUTFILE.open(outputfile,ios::out);

};

void Finalize(DATAFILE_t &DATAFILE, OUTFILE_t &OUTFILE)
{
        cout<<"Now closing input and output files...."<<endl;
        DATAFILE.close();
        OUTFILE.close();
        cout<<"Terminating program.....GOODBYE..."<<endl;
};

anyone have have suggestions?

Datafile, etc. in main() bear no relation to the names you have given to your parameters in your method definitions. Just make a variable of datatype OUTPUT_t and one of DATAFILE_t within the body of main()and pass them into your methods. These variables are being passed in by reference so the reference will be to the two variables in main() as they pass through the methods.

cStudent::cStudent(); is incorrect. When you are declaring your tempstudent on the line before your default constructor is already being called.

Also main() should explicitly be defined as returning and int and should have a return 0; at the very end.

P.S. Please use code tags or highlight the code and hit the [code] button on the toolstrip of the editing box.

I really really HATE two things about your code style: (1) CAPITALIZING FUNCTION NAMES, and (2) typedef'ing standard c++ class names. All that accomplishes is making your program more difficult to read and understand. You should be coding for clarity, not attempting to impress your teacher or others with an obnoxious coding style.

commented: I really really hate that too +3
commented: I wasn't gonna say anything... hehe. I figured OP missed FORTRAN since he had a READ method (no WRITE(*,*) though) +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.