Hi guys im a beginner at programming i started a book for beginners im only on lopps now but as uasuall i googled and wondered off into classes i keep getting this error, i initialized the float variables in the class by using the constructor. I'm not sure if this is the right way, please help ::)

#include <iostream>
#include <time.h>
#include <string>

using namespace std;
// Function Declarations
string ToUpper(string string1);
///////////////////////////////
class Student
{
    float eMidterm;
    float eFinal;
    float eResearch;
    float ePresentation;
    float sMidterm;
    float sFinal;
    float sResearch;
    float mMidterm;
    float mFinal;
    // Constructor Function
public:Student();
    ////////////////////////// Grades Variables
public:
    int midterm;
    int presentation;
    int research;
    int finalexam;
public: float setEnglish(int midterm, int finalexam, int research, int presentation);
};
// Constructor Funtion used to Initialize the class members
Student::Student()
{
    eMidterm = .25f;
    eFinal = .25f;
    eResearch = .30f;
    ePresentation = .20f;
}
/////////////////////////////////////////////////////////////
// setEnglish
float setEnglish(int midterm, int finalexam, int research, int presentation)
{
    Student::Student();
    float finalNumericGrade =
        (midterm * eMidterm) +
        (finalexam * eFinal) +
        (research * eResearch) +
        (presentation * ePresentation);
    return finalNumericGrade;
}
/////////////////////////////////////////////////////////////
int main(void) // MAIN FUNCTION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
{
    // Variables 
    string response;
    int midterm;
    int finalexam;
    int research;
    int presentation;
    float finalNumericGrade;

    cout << "\n*****     Welcome to the Grade Calculation Program     *****\n\n";
    cout << "Do you have a grade to calculate(Yes/No) :  ";
    getline(cin, response);

    response = ToUpper(response);
    while(response.length() == 0)
    {
        cout << "\nDo you have a grade to calculate(Yes/No) :  ";
        getline(cin, response);
    }
    if(response == "NO")
    {
        cout << "\n\nThank - You for using the Grade Calculation Program!!\n\n";
        system("PAUSE");
        return 0;
    }
    // Main program loop
    while(response.compare("YES")  == 0)
    {
        cout << "\n\nEnter Student Type(1: English, 2: Maths, 3: Science) :  ";
        getline(cin, response);
        while(response.length() == 0)
        {
            cout << "\nEnter Student Type(1: English, 2: Maths, 3: Science) :  ";
            getline(cin, response);
        }

        switch(stoi(response))
        {
        case 1:
            Student eStudent;
            cout << "\n\nEnglish Student\n\n"
                 << "Enter Midterm Grade     :  ";
            getline(cin, response);
            midterm = stoi(response);
            cout << "Enter Final Exam Grade  :  ";
            getline(cin, response);
            finalexam = stoi(response);
            cout << "Enter Research Grade    :  ";
            getline(cin, response);
            research = stoi(response);
            cout << "Enter Presentation Grade:  ";
            getline(cin, response);
            presentation = stoi(response);
            eStudent.setEnglish(midterm, finalexam, research, presentation);
            break;
        }
    }
}
////////////////////////////////////////////////////////////////////////


// End of Main And start of my functions  
string ToUpper(string string1)
{
    for(int x = 0; x < string1.length(); x++)
    {
        string1[x] = toupper(string1[x]);
    }
    return string1;
}
///////////////////////////////////////

Recommended Answers

All 2 Replies

line 40: you forgot the class name before function name. float Student::setEnglish(

Thanks man working now, very stupid mistake :) sorry

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.