well... its me again with another project following the basics of the last one...

heres my header file:

#ifndef SCHEDULE_H 
#define SCHEDULE_H 

#include<string> 

class schedule 
{ 
      public: 
              
              // this section will display the heading for the output table 
             void printHead (); 
                                              
              
              //This function is used to calculate the totalgpa for one class 
             int calcGradePoint(aGrade, int, int&);    
              
              
              //This bubblesort is used to put the courses into alphabetical order 
             void sortClass(string, int, char, int);    
            
            
              //This function is used to calculate overall gpa = totalofgpa / totalhours 
             float calcGPA(float, int);  
                        
              
              //this function will print the output lines in the table 
             void printLine ();    
                              
              
      private: 
              
              int hours[50], cnt = 0;                //Variables used 
              char grades[50], gpaForOneClass[50]; 
              string courses[50];  
              float gpa = 0.0, totalHours = 0, gpaSum = 0; 
              gradevalue in; 
              enum aGrade {a, b, c, d, f, w, i}; 
              
                    
}; 
#endif // SCHEDULE_H

and here is my schedule.cpp:

#include "schedule.h" 
#include<iostream>  // all the classes I could ever need for this program 
#include<iomanip>   // and a few extra just incase. 
#include<cmath> 
#include<cstdlib> 
#include<string> 
using namespace std; 

enum aGrade {a, b, c, d, f, w, i}; 


    int hours[50], cnt = 0;                //Variables used 
    char grades[50], gpaForOneClass[50]; 
    string courses[50];  
    float gpa = 0.0, totalHours = 0, gpaSum = 0; 
    aGrade in; 


void schedule::printHead ()  // this section will display the heading for the output table 
{ 
     cout<<"\n\nList of the Courses"<<endl<<"\n       Class      Hours     Grade       \n"; 
     cout<<"-----------------------------------"<<endl; 
} 

aGrade convert(aGrade in,     //OUT: in 
                   char grades)       //IN: grades 
                                            
{                                                
  switch (grades)      //switch stmt to get all the letters into the enum catagories                        
    { 
      case 'a':case 'A': 
        in = a; 
        break; 
      case 'b':case 'B': 
        in = b; 
        break; 
      case 'c':case 'C': 
        in = c; 
        break; 
      case 'd':case 'D': 
        in = d; 
        break; 
      case 'f':case 'F': 
        in = f; 
        break; 
      case 'w':case 'W': 
        in = w; 
        break; 
      case 'i':case 'I': 
        in = i; 
        break; 
                                                
    } 
                                                                                
  return in; 
} 
                                                                                
int schedule::calcGradePoint(aGrade in,  //IN: in 
                   int hours,    // IN: hours 
                   int& cnt)     //INOUT: cnt 
           //This function is used to calculate the totalgpa for one class                                      
                                                
{                                      
 if(in == a)      
   return 4 * hours; 
 if(in == b) 
   return 3 * hours; 
 if(in == c) 
   return 2 * hours; 
 if(in == d) 
   return 1 * hours; 
 if(in == f) 
    return 0 * hours; 
 if(in == w) 
    return 0 * hours; 
 if(in == i) 
    return 0 * hours; 
 else 
    cout<<"\nInvalid entry"<<endl; 
    cnt = cnt - 1; 
} 
                                                                                

void schedule::sortClass(string courses[],   //INOUT: courses 
           int hours[],       //INOUT: hours 
           char grades[],     //INOUT: grades 
           const int cnt)    //IN: cnt 
            //This bubblesort is used to put the courses into alphabetical order 

{                                  
      int i = cnt, j = 0, k = 1, temper; 
      string temp; 
      char tmp; 
      
      while (i >= 0 && k) 
      { 
              
            k = 0; 
            for (j = 0; j <= i; j++) 
                 if (courses[j] > courses[j+1]) 
                 { 
                       temp = courses[j]; 
                       courses[j] = courses[j+1]; 
                       courses[j+1] = temp; 
                        
                       temper = hours[j]; 
                       hours[j] = hours[j+1]; 
                       hours[j+1] = temper; 
                        
                       tmp = grades[j]; 
                       grades[j] = grades[j+1]; 
                       grades[j+1] = tmp; 
                  
                       k = 1; 
                  } 
            i--; 
            } 
} 


    
float schedule::calcGPA(const float gpaSum,    //IN: gpaSum 
             const int totalHours )  //IN:  totalHours 
                //This function is used to calculate overall gpa = totalofgpa / totalhours 

{                                          
      float gpa; 
      gpa = float (gpaSum / totalHours); 
      return gpa; 
} 


void schedule::printLine (const int cnt, int b, string courses[], int hours[], char grades[], float gpa, int totalHours) 
{ 
      for (int b = 1; b <= cnt; b++)  //puts the information into the table 
      { 
          cout<<setw(12)<<courses[b]<<setw(9)<<hours[b]<<setw(10)<<grades[b]<<endl; 
      } 
    
      cout<<"\nThe total GPA is "<<gpa<<" and you attempted "<<totalHours<<" hours."<<endl; 
}

here are my compiling errors.

64 schedule.cpp prototype for ` int schedule::calcGradePoint(aGrade, int, int&)' does not match any in class

15 schedule.h int schedule::calcGradePoint()

91 schedule.cpp prototype for ` void schedule::sortClass(std::string*, int*, char*, int)' does not match any

19 schedule.h void schedule::sortClass()

127 schedule.cpp prototype for ` float schedule::calcGPA(float, int)' does not match any in class `schedule'

23 schedule.h float schedule::calcGPA()

135 schedule.cpp prototype for ` void schedule::printLine(int, int, std::string*, int*, char*, float, int)'

27 schedule.h void schedule::printLine()


heres my grading points for this lab:

Grading Points:
1) Use the following type definitions:
enum aGrade {A, B, C, D, F, W, I};
struct aClass
{
string course;
aGrade grade;
int hours;
int GP;
};
2) All variables must be local.
3) All functions and type definitions must be in a header file (*.h).
4) All function bodies must be in a separate body file (*.cpp) from the main.
5) An array of 10 structures of type aClass will make up the storage mechanism; i.e., you will process 10 students.
6) Comment all functions thoroughly: InOut, Out, requires, ensures.
7) Input must be inline (i.e. all values entered on the same line)
$>class grade hours
8 ) Allow both upper and lower case entries for grades.
9) Accept “quit, “Quit, and “QUIT as acceptable terminators for loop
10) Use the following functions:
printHead //Prints the top of the display chart
printLine //Prints 1 line of the table
calcGradePoints //Calculates grade points for structure
calcGPA //Calculates total GPA
sortClass //Uses a bubble sort to put classes in order


I and reading in my text book and trying to figure this out... i dont care about the struct yet. And i didn't include my main function. I just want to see where i am going wrong with this header file/class

void schedule::printLine (const int cnt, int b, string courses[], int hours[], char grades[], float gpa, int totalHours)
//this function will print the output lines in the table 
             void printLine ();

The definition is different than the prototype...
try this in the class declaration:

void printLine(const int, int, string [], int [], char p[], float, int);

I posted this again because i got alot more errors for some reason... then
turned around and got rid of most of the errors? only down to four now... not sure what happened in those few minutes.

#ifndef SCHEDULE_H
#define SCHEDULE_H

#include<string>

class schedule
{
      public:
             
             schedule();
             
             enum aGrade {a, b, c, d, f, w, i};
             
              // this section will display the heading for the output table
             void printHead ();
                                             
             
              //This function is used to calculate the totalgpa for one class
             int calcGradePoint();   
             
             
              //This bubblesort is used to put the courses into alphabetical order
             void sortClass(std::string, int, char, int);   
            
            
              //This function is used to calculate overall gpa = totalofgpa / totalhours
             float calcGPA(float, int);  
                       
              
              //this function will print the output lines in the table
             void printLine();  
                             
             
      private:
              
              int hours[50], cnt;                //Variables used
              char grades[50], gpaForOneClass[50];
              std::string courses[50];  
              float gpa, totalHours, gpaSum;
              
              
                    
};
#endif // SCHEDULE_H

and .cpp

#include "schedule.h"
#include<iostream>  // all the classes I could ever need for this program
#include<iomanip>   // and a few extra just incase.
#include<cmath>
#include<cstdlib>
#include<string>
using namespace std;

enum aGrade {a, b, c, d, f, w, i};

schedule::schedule()
{
    int cnt = 0;                //Variables used
    float gpa = 0.0;
    float totalHours = 0;
    float gpaSum = 0;
    
}

void schedule::printHead ()  // this section will display the heading for the output table
{
     cout<<"\n\nList of the Courses"<<endl<<"\n       Class      Hours     Grade       \n";
     cout<<"-----------------------------------"<<endl;
}

aGrade convert(enum aGrade in,     //OUT: in
                   char grades)       //IN: grades
                                            
{                                                
  switch (grades)      //switch stmt to get all the letters into the enum catagories                       
    {
      case 'a':case 'A':
        in = a;
        break;
      case 'b':case 'B':
        in = b;
        break;
      case 'c':case 'C':
        in = c;
        break;
      case 'd':case 'D':
        in = d;
        break;
      case 'f':case 'F':
        in = f;
        break;
      case 'w':case 'W':
        in = w;
        break;
      case 'i':case 'I':
        in = i;
        break;
                                                
    }
                                                                                
  return in;
}
                                                                                
int schedule::calcGradePoint(enum aGrade in,  //IN: in
                   int hours[],    // IN: hours
                   int& cnt)     //INOUT: cnt
           //This function is used to calculate the totalgpa for one class                                      
                                                
{                                     
 if(in == a)      
   return 4 * hours[cnt];
 if(in == b)
   return 3 * hours[cnt];
 if(in == c)
   return 2 * hours[cnt];
 if(in == d)
   return 1 * hours[cnt];
 if(in == f)
    return 0 * hours[cnt];
 if(in == w)
    return 0 * hours[cnt];
 if(in == i)
    return 0 * hours[cnt];
 else 
    cout<<"\nInvalid entry"<<endl;
    cnt = cnt - 1;
}
                                                                                

void schedule::sortClass(string courses[],   //INOUT: courses 
           int hours[],       //INOUT: hours
           char grades[],     //INOUT: grades
           const int cnt)    //IN: cnt
            //This bubblesort is used to put the courses into alphabetical order

{                                 
      int i = cnt, j = 0, k = 1, temper;
      string temp;
      char tmp;
      
      while (i >= 0 && k)
      {
             
            k = 0;
            for (j = 0; j <= i; j++)
                 if (courses[j] > courses[j+1])
                 {
                       temp = courses[j];
                       courses[j] = courses[j+1];
                       courses[j+1] = temp;
                       
                       temper = hours[j];
                       hours[j] = hours[j+1];
                       hours[j+1] = temper;
                       
                       tmp = grades[j];
                       grades[j] = grades[j+1];
                       grades[j+1] = tmp;
                 
                       k = 1;
                  }
            i--;
            }
}


    
float schedule::calcGPA(const float gpaSum,    //IN: gpaSum
             const int totalHours )  //IN:  totalHours
                //This function is used to calculate overall gpa = totalofgpa / totalhours

{                                         
      float gpa;
      gpa = float (gpaSum / totalHours);
      return gpa;
}


void schedule::printLine ()
{
      for (int b = 1; b <= cnt; b++)  //puts the information into the table
      {
          cout<<setw(12)<<courses[b]<<setw(9)<<hours[b]<<setw(10)<<grades[b]<<endl;
      }
    
      cout<<"\nThe total GPA is "<<gpa<<" and you attempted "<<totalHours<<" hours."<<endl;
}

errors::

65 schedule.cpp prototype for ` int schedule::calcGradePoint(schedule::aGrade, int*, int&)' does not match

20 schedule.h int schedule::calcGradePoint()

92 schedule.cpp prototype for ` void schedule::sortClass(std::string*, int*, char*, int)' does not match any

24 schedule.h void schedule::sortClass(std::basic_string<char, std::char_traits<char>,

[edit]Saw the second post not as bad[/edit]
Some tips:
1. Don't use the same variable names for the names of parameters.
2. Make sure that you actully have a function prototyped in your header.
3. Make sure that the function you prototyped in your header matches that one that you have defined in your class.
4. You can't assign a value for a data member in your class in the header you do that in the constructor or use a "setter" function.
4. Maybe work on your spacing it's wierd not the worst I have seen but I don't like it.

Only getting one error message now...

[Linker error] undefined reference to `WinMain@16'

?? im lost.

just a quick question... if you run a win32 console...

you have to have a main in your project to work without the errors right??

say you have a header and another .cpp that contains the functions defined in the header, you have to include the other .cpp file with the main to get rid of such errors as...

[Linker error] undefined reference to `WinMain@16'

right?

if you run a win32 console...

you have to have a main in your project to work without the errors right??

Yes.

say you have a header and another .cpp that contains the functions defined in the header, you have to include the other .cpp file with the main to get rid of such errors as...

[Linker error] undefined reference to `WinMain@16'

right?

First, I hope you are not meaning include in the #include sense. But I believe yes -- there must be exactly one main, and it doesn't really matter in which source file it is located.

no i didnt mean it in the #include sense.

I meant.. your project file must CONTAIN not include...

sorry for the misrepresentation.

but now i am curious what this error means?

C:\Documents and Settings\Josh\Desktop\Makefile.win [Build Error] [cs110lab5.o] Error 1

i have a schedule.h
a schedule.cpp
and then the file that contains my main is cs110lab5.cpp

This article has been dead for over six months. Start a new discussion instead.