I am making a mock financial aid account for a project and I wanted to know why my program is not working. Can anyone help me out?? After creating my class, I am trying to access my getName(student_name) function in my main(). It says: "error C2065: 'student_name' : undeclared identifier". How can it be undeclared when I did #include "Financial_Aid_.h" in my main_program.cpp file?? Can someone answer this for me please? Thank You guys and gals for looking at my post. Here is my code.
This is my Financial_Aid_.h header file
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <ctime>
#include <conio.h>
#include <string>
using namespace std;
class Financial_Aid_Data
{
private:
string name;
float student_id, scholarship_amt;
int awards;
public:
Financial_Aid_Data() /* constructor */
{
name = "unknown";
student_id = 123456;
scholarship_amt = 0;
awards = 0;
}
string getName(string student_name)
{
cout << "What is your name? ";
getline(cin, student_name);
cout << endl << endl;
name = student_name;
return name;
}
float getIdNumber(float student_id_num)
{
cout << "What is your student id number? ";
cin >> student_id_num;
student_id = student_id_num;
cout << endl << endl;
return student_id;
}
int getAwardAmount(int amt_of_awards)
{
cout << "How many awards do you have? ";
cin >> amt_of_awards;
awards = amt_of_awards;
cout << endl << endl;
return awards;
}
float getScholarship_amount(int awards, float my_scholarship)
{
vector<float>num_of_awards;
for(int i = 0; i < awards; i++)
{
cout << "How much is this scholarship worth? ";
cin >> my_scholarship;
num_of_awards.push_back(my_scholarship);
cout << endl << endl;
}
for(float x = 0; x <= num_of_awards.size(); x++)
{
scholarship_amt += x;
}
cout << "Your amount is: " << scholarship_amt << endl;
return scholarship_amt;
}
void Display()
{
cout << "Your name is: " << name << endl << endl;
cout << "Your id is: " << student_id << endl << endl;
cout << "Your scholarship amount is: $" << scholarship_amt << " from " << awards << " awards." << endl;
}
};
And this is in my main_program.cpp
#include "Financial_Aid_.h"
void Continue()
{
char c;
cout << "Press any key to continue... "; c = _getch();
}
int main()
{
Financial_Aid_Data Student_Data;
Student_Data.getName(student_name);
Continue();
return 0;
}