Compiler error: not declared in the scope - c++

I am trying to test my code for a few classes that I have created, but I'm running into some difficulties in trying to compile. I have three class and a main class. The first class is a person class and the second and third are student and faculty which is derived from person.
Here is what I have for the Person.h class:
#ifndef Person_H
#define Person_H
#include <string>
using namespace std;
class Person
{
protected:
long id;
string name;
string email;
string address;
string dateOfBirth;
string gender;
public:
Person(long pId);
Person(long pId, string pName, string pEmail, string pAddress, string pDateOfBirth, string pGender);
void print() const;
};
#endif
Here is my Person.C
#include <iostream>
#include "Person.h"
using namespace std;
Person::Person(long pId)
{
id = pId;
name = "Nothing";
email = "Nothing";
address = "Nothing";
dateOfBirth = "Nothing";
gender = "Nothing";
}
Person::Person(long pId, string pName, string pEmail, string pAddress, string pDateOfBirth, string pGender)
{
id = pId;
name = pName;
email = pEmail;
address = pAddress;
dateOfBirth = pDateOfBirth;
gender = pGender;
}
void Person::print() const
{
cout << "ID: " << id << endl;
cout << "Name: " << name << endl;
cout << "Email: " << email << endl;
cout << "Address: " << address << endl;
cout << "Date of Birth: " << dateOfBirth << endl;
cout << "Gender: " << gender << endl;
}
here is the Student.h
#ifndef Student_H
#define Student_H
#include<string>
#include <vector>
#include "Person.h"
#include "Course.h"
using namespace std;
class Student:public Person
{
protected:
int yearOfStudy;
string major;
long advisorId;
vector <Course> coursesTaken;
static long nextStId;
public:
Student();
Student(string sName, string sEmail, string sAddress, string sDateOfBirth, string sG\
ender, int sYearOfStudy, string sMajor, long sAdvistorId);
void print() const;
};
#endif
Here is the Student.C
#include<iostream>
#include "Student.h"
using namespace std;
long Student::nextStId = 500;
Student::Student():Person(nextStId)
{
yearOfStudy = 0;
major = " ";
advisorId = 0;
}
Student::Student(string sName, string sEmail, string sAddress, string sDateOfBirth, st\
ring sGender, int sYearOfStudy, string sMajor, long sAdvisorId):Person(nextStId, sName\
, sEmail, sAddress,sDateOfBirth, sGender)
{
yearOfStudy = sYearOfStudy;
major = sMajor;
advisorId = sAdvisorId;
}
void Student::print() const
{
Person::print();
cout << "Year of study: " << yearOfStudy << endl;
cout << "Major: " << major << endl;
cout << "Advisor ID: " << advisorId << endl;
}
Now in my main, I have:
#include <iostream>
#include <string>
#include "Faculty.h"
#include "Student.h"
#include "Person.h"
using namespace std;
int main()
{
Student test1;
Faculty test2;
test1.print();
cout << endl;
test2.print();
return 0;
}
The error that I receive when I try to compile is:
g++ Assignment3.C Person.C Student.C Faculty.C
Assignment3.C: In function âint main()â:
Assignment3.C:10: error: âStudentâ was not declared in this scope
Assignment3.C:10: error: expected `;' before âtest1â
Assignment3.C:12: error: âtest1â was not declared in this scope
I don't understand why it's giving me that error. My faculty class seems to running perfectly fine. Could someone help please!

I'm not specialist, but don't you need have () after test1? Like Student test1 (); I know it's not related to the error, but you can check.

Related

Undefined reference to Artist::Artist and Artwork::Artwork [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 5 months ago.
I'm new to this multi-file class stuff and I've got an undefined reference for both of my classes and I think it has something to do with my initialization and default constructor but honestly have no clue if any of this is correct at all. Any help is greatly appreciated.
main.cpp
#include "Artist.h"
#include "Artwork.h"
#include <iostream>
#include <string>
using namespace std;
int main() {
string userTitle, userArtistName;
int yearCreated, userBirthYear, userDeathYear;
getline(cin, userArtistName);
cin >> userBirthYear;
cin.ignore();
cin >> userDeathYear;
cin.ignore();
getline(cin, userTitle);
cin >> yearCreated;
cin.ignore();
Artist userArtist = Artist(userArtistName, userBirthYear, userDeathYear);
Artwork newArtwork = Artwork(userTitle, yearCreated, userArtist);
newArtwork.PrintInfo();
}
Artist.h
#ifndef ARTISTH
#define ARTISTH
#include <string>
using namespace std;
class Artist{
public:
Artist();
Artist(string artistName, int birthYear, int deathYear);
string GetName() const;
int GetBirthYear() const;
int GetDeathYear() const;
void PrintInfo() const;
private:
string artistName;
int birthYear;
int deathYear;
};
#endif
Artist.cpp
#include "Artist.h"
#include <iostream>
#include <string>
using namespace std;
Artist::Artist()
{
artistName = "unknown";
birthYear = -1;
deathYear = -1;
}
string Artist::GetName() const
{
return artistName;
}
int Artist::GetBirthYear() const
{
return birthYear;
}
int Artist::GetDeathYear() const
{
return deathYear;
}
void Artist::PrintInfo() const
{
if(deathYear > 0 && birthYear > 0)
{
cout << "Artist: " << artistName <<" ("<< birthYear << " to "<< deathYear << ")" <<
endl;
}
else if(birthYear > 0 && deathYear < 0)
{
cout << "Artist: " << artistName <<" ("<< birthYear << " to present)" << endl;
}
else if(birthYear<0 && deathYear<0)
{
cout << "Artist: " << artistName << " (unknown)" << endl;
}
}
Artwork.h
#ifndef ARTWORKH
#define ARTWORKH
#include "Artist.h"
class Artwork{
public:
Artwork();
Artwork(string title, int yearCreated, Artist artist);
string GetTitle();
int GetYearCreated();
void PrintInfo();
private:
string title;
int yearCreated;
Artist artist;
};
#endif
Artwork.cpp
#include "Artwork.h"
#include <iostream>
Artwork::Artwork()
{
cout <<"Artwork has started." << endl;
title = "unknown";
yearCreated = -1;
Artist artist(); //here im not sure how to initialize an object inside of an object
}
string Artwork::GetTitle()
{
return title;
}
int Artwork::GetYearCreated()
{
return yearCreated;
}
void Artwork::PrintInfo()
{
artist.PrintInfo();
cout << "Title: " << title << ", " << yearCreated << endl;
}
I was correct, i needed to initialize both a default(no input parameters) constructor and a constructor with input parameters.
to correctly write a default and parameter constructor, do this
Artwork::Artwork(string n, int y, Artist a)
{
title = n;
yearCreated = y;
artist = a;
}//constructor with given input
Artwork::Artwork()
{
title = "unknown";
yearCreated = -1;
}//if input is not given for any fields, refer to this constructor
Notice that the default constructor does not have an object, I'm honestly not sure if there is a way to initialize a blank object and if so, why that isn't necessary.
The Artist constructor looks the same,
Artist::Artist(string name, int birth, int death)
{
artistName = name;
birthYear = birth;
deathYear = death;
}
Artist::Artist()
{
artistName = "unknown";
birthYear = -1;
deathYear = -1;
}

'class' type redefinition rejection

Having some issues with my two classes and having issues with my account files. I'm not fully sure how to go about fixing it with the classes I think being defined twice. I looked through other suggestions on how to fix it and I'm not exactly sure where to go with it. All the error says is 'Account:' 'class' type redefinitions
Account.h
#include <string>
class Account
{
private:
unsigned int accountNumber;
std::string firstName, lastName;
double balance;
static unsigned int count;
public:
Account();
void setFirstName(std::string fName);
void setLastName(std::string lName);
void setBalance(double inBalance);
void display();
};
this would be the main file
Account.cpp
#include "Account.h"
#include <iostream>
using namespace std;
//Initializes the static counter set equal to 0
unsigned int Account::count = 0;
//Sets up a default constructor
Account::Account()
{
count++;
//Set accountNumber to count
accountNumber = count;
}
//Sets up the first name
void Account::setFirstName(std::string fName)
{
firstName = fName;
}
//Sets up the last name
void Account::setLastName(std::string lName)
{
lastName = lName;
}
//Sets up the balance
void Account::setBalance(double inBalance)
{
balance = inBalance;
}
//Displays the details of the Account
void Account::display()
{
cout << fixed;
cout.precision(2);
cout << "Balance: " << balance << endl;
cout << "Account: " << accountNumber << endl;
cout << "First Name: " << firstName << endl;
cout << "Last Name: " << lastName << endl;
}
You need include guards in your header file
#ifndef ACCOUNT_H_
#define ACCOUNT_H_
#include <string>
class Account
{
private:
unsigned int accountNumber;
std::string firstName, lastName;
double balance;
static unsigned int count;
public:
Account();
void setFirstName(std::string fName);
void setLastName(std::string lName);
void setBalance(double inBalance);
void display();
};
#endif
this prevents the header being included twice in one file

Undefined Symbol in inherited classes for member Functions C++

So I'm writing a Manager class which inherits from SalariedEmployee which inherits from Employee. I have the employee.h header file and employee.cpp header file and also for salariedemployee as shown below.
I cant seem to understand why I get the following errors when I try to compile the code of
Undefined symbol: employeessavitch::SalariedEmployee::SalariedEmployee()
Undefined symbol: employeessavitch::SalariedEmployee::SalariedEmployee()
Undefined symbol: employeessavitch::SalariedEmployee::get_salary() const
Undefined symbol: employeessavitch::Employee::get_ssn() const
Undefined symbol: employeessavitch::Employee::get_name() const
Here are my files
employee.h
#ifndef employee_h
#define employee_h
#include <string>
#include "employee.h"
using namespace std;
namespace employeessavitch
{
class Employee
{
public:
Employee();
Employee(string the_name, string the_ssn);
string get_name( ) const;
string get_ssn( ) const;
double get_net_pay( ) const;
void set_name(string new_name);
void set_ssn(string new_ssn);
void set_net_pay(double new_net_pay);
void print_check( ) const;
protected:
string name;
string ssn;
double net_pay;
};
}
#endif /* employee_h */
employee.cpp
#include <string>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include "employee.h"
using namespace std;
namespace employeessavitch
{
Employee::Employee(): name("No name yet"), ssn("No number yet"), net_pay(0)
{
//deliberately empty
}
Employee::Employee(string the_name, string the_ssn)
{
//deliberately empty
}
Employee::Employee(string the_name, string the_number): name(the_name), ssn(the_number), net_pay(0)
{
//deliberately empty
}
string Employee::get_name() const
{
return name;
}
string Employee::get_ssn() const
{
return ssn;
}
double Employee::get_net_pay() const
{
return net_pay;
}
void Employee::set_name(string new_name)
{
name = new_name;
}
void Employee::set_ssn(string new_ssn)
{
ssn = new_ssn;
}
void Employee::set_net_pay (double new_net_pay)
{
net_pay = new_net_pay;
}
void Employee::print_check( ) const
{
cout << "\nERROR: print_check FUNCTION CALLED FOR AN \n"
<< "UNDIFFERENTIATED EMPLOYEE. Aborting the program.\n"
<< "Check with the author of the program about this bug.\n";
exit(1);
}
}//employeessavitch
salariedemployee.h
#ifndef salariedemployee_h
#define salariedemployee_h
#include <string>
#include "employee.h"
#include "salariedemployee.h"
namespace employeessavitch
{
class SalariedEmployee : public Employee
{
public:
SalariedEmployee();
SalariedEmployee (string the_name, string the_ssn, double the_weekly_salary);
double get_salary() const;
void set_salary(double new_salary);
void print_check();
protected:
double salary;//weekly
};
}//employeessavitch
#endif /* salariedemployee_h */
salariedemployee.cpp
#include <iostream>
#include <string>
#include <stdio.h>
#include "salariedemployee.h"
using namespace std;
namespace employeessavitch
{
SalariedEmployee::SalariedEmployee() //: Employee(), salary(0)
{
//deliberately empty
}
SalariedEmployee::SalariedEmployee(string the_name, string the_number, double the_weekly_salary)//: Employee(the_name, the_number), salary(the_weekly_salary)
{
//deliberately empty
}
double SalariedEmployee::get_salary() const
{
return salary;
}
void SalariedEmployee::set_salary(double new_salary)
{
salary = new_salary;
}
void SalariedEmployee::print_check()
{
set_net_pay(salary);
cout << "\n__________________________________________________\n";
cout << "Pay to the order of " << get_name( ) << endl;
cout << "The sum of " << get_net_pay( ) << " Dollars\n";
cout << "_________________________________________________\n";
cout << "Check Stub NOT NEGOTIABLE \n";
void SalariedEmployee::print_check()
{
set_net_pay(salary);
cout << "\n__________________________________________________\n";
cout << "Pay to the order of " << get_name( ) << endl;
cout << "The sum of " << get_net_pay( ) << " Dollars\n";
cout << "_________________________________________________\n";
cout << "Check Stub NOT NEGOTIABLE \n";
cout << "Employee Number: " << get_ssn( ) << endl;
cout << "Salaried Employee. Regular Pay: "
<< salary << endl;
cout << "_________________________________________________\n";
}
}//employeessavitch
main.cpp
#include <iostream>
#include <cstring>
#include <string>
#include <string.h>
#include <fstream>
#include "salariedemployee.h"
#include "employee.h"
using namespace std;
namespace employeessavitch
{
class Manager: public SalariedEmployee
{
public:
Manager();
~Manager();
void addReport(SalariedEmployee employee);
friend ostream& operator <<(ostream &outs, Manager manager);
private:
SalariedEmployee *reports;
int noReport;
};
Manager::Manager()
{
noReport = 0;
}
Manager::~Manager()
{
delete[] reports;
}
void Manager::addReport(SalariedEmployee employee)
{
SalariedEmployee *report = new SalariedEmployee[noReport+1];
for(int i = 0; i < noReport; i++)
{
report[i] = reports[i];
}
report[noReport+1] = employee;
delete[] reports;
}
ostream& operator <<(ostream &outs, Manager manager)
{
for(int i = 0; i < manager.noReport; i++)
{
outs << manager.reports[i].get_name() << endl;
outs << manager.reports[i].get_ssn() << endl;
outs << manager.reports[i].get_salary() << endl;
}
return outs;
}
}
int main()
{
cout << "hello world";
return 0;
}

Cout not printing out expected results

When I compile the below code, for some reason, the student/instructors name, age, and GPA/Rating, are not returned via their respective printPerson functions.
With the name variable, nothing is printed to the console.
With the age, GPA/Rating, console prints out a negative 8 digit number, and a negative float.
What am I not seeing?
Person.h
#pragma once
#ifndef PERSON_H
#define PERSON_H
#include <iostream>
#include <vector>
#include <string>
using std::string;
// Base class
class Person {
protected:
string name;
int age;
public:
void setName(string name);
void setAge(int age);
virtual void do_work(int number) {};
virtual void printPerson() {};
};
#endif;
Person.cpp
#include "Person.h"
#include <iostream>
#include <vector>
#include <string>
using std::cout;
using std::cin;
using std::endl;
void Person::setName(string name) {
name = name;
}
void Person::setAge(int age) {
age = age;
}
Student.h
#pragma once
#ifndef STUDENT_H
#define STUDENT_H
#include <iostream>
#include <vector>
#include <string>
#include "Person.h"
using std::string;
class Student : public Person {
private:
float gpa;
public:
void setGPA(float gpa);
float getGPA();
void do_work(int number);
void printPerson();
};
#endif;
Student.cpp
#include "Student.h"
#include <iostream>
#include <vector>
#include <string>
using std::string;
using std::cout;
using std::cin;
using std::endl;
void Student::setGPA(float gpa) {
gpa = gpa;
}
float Student::getGPA() {
return gpa;
}
void Student::do_work(int number) {
//cout << name << ".. " << number << "hours of homework.” << endl;
cout << name;
}
void Student::printPerson() {
cout << "Name : " << name << "Age :" << age << " GPA : " << getGPA() << endl;
}
Instructor.h
#pragma once
#ifndef INSTRUCTOR_H
#define INSTRUCTOR_H
#include <iostream>
#include <vector>
#include <string>
#include "Person.h"
class Instructor : public Person {
private:
float rating;
public:
void setRating(float rating);
float getRating();
void do_work(int number);
void printPerson();
};
#endif;
Instructor.cpp
#include "Instructor.h"
#include <iostream>
#include <vector>
#include <string>
using std::string;
using std::cout;
using std::cin;
using std::endl;
void Instructor::setRating(float rating) {
rating = rating;
}
float Instructor::getRating() {
return rating;
}
void Instructor::do_work(int number) {
cout << name << "graded papers for" << number << "hours." << endl;
}
void Instructor::printPerson() {
cout << " Name : " << name << " Age : " << age << " Rating : " << getRating() << endl;
}
University.h
#pragma once
#ifndef UNIVERSITY_H
#define UNIVERSITY_H
#include <iostream>
#include <vector>
#include <string>
#include "Person.h"
#include "Building.h"
#include "Student.h"
using std::cout;
using std::string;
using std::vector;
class University {
public:
string name;
vector<Person*> persons;
vector<Building> buildings;
public:
void printAllBuildings();
void printAllPersonsRecord();
};
#endif;
University.cpp
#include "University.h"
#include <iostream>
#include <vector>
#include <string>
using std::string;
using std::cout;
using std::cin;
using std::endl;
void University::printAllBuildings() {
cout << " Building Details : " << endl;
for (int j = 0; j < buildings.size(); j++) {
buildings[j].printBuilding();
}
}
void University::printAllPersonsRecord() {
cout << " Persons Details : " << endl;
for (int i = 0; i < persons.size(); i++) {
persons[i]->printPerson();
}
}
Building.h
#pragma once
#ifndef BUILDING_H
#define BUILDING_H
#include <iostream>
#include <vector>
#include <string>
#include "Person.h"
class Building {
public:
string name;
int size;
string address;
public:
void printBuilding();
};
#endif;
Building.cpp
#include "Building.h"
#include <iostream>
#include <vector>
#include <string>
using std::string;
using std::cout;
using std::cin;
using std::endl;
void Building::printBuilding() {
cout << " Name : " << name << " Address : " << address << endl;
}
main.cpp
#include "University.h"
#include "Person.h"
#include "Student.h"
#include "Instructor.h"
#include <iostream>
#include <vector>
#include <string>
using std::string;
using std::cout;
using std::cin;
using std::endl;
int main() {
Student student;
Instructor instructor;
student.setName("deepak");
student.setAge(12);
student.setGPA(12.0);
instructor.setName("rajdev");
instructor.setAge(23);
instructor.setRating(5.0);
Building building;
building.name = "block1";
building.size = 2000;
building.address = "noida sector-2";
Building building2;
building2.name = "block2";
building2.size = 4000;
building2.address = "noida sector-2";
University university;
university.name = "Oregon State University";
university.persons.emplace_back(&student);
university.persons.emplace_back(&instructor);
university.buildings.push_back(building);
university.buildings.push_back(building2);
university.printAllBuildings();
university.printAllPersonsRecord();
int choice;
bool isValidMainChoice = false;
while (!isValidMainChoice) {
cout << "Kindly choose one of the option from follwoing list of operations or Menu" << endl;
cout << "1 : Prints names of all the buildings" << endl;
cout << "2 : Prints names of everybody at the university" << endl;
cout << "3 : Choose a person to do work" << endl;
cout << "4 : Exit the program" << endl;
cin >> choice;
cout << "The value you entered is " << choice << endl;
if (choice == 1) {
university.printAllBuildings();
}
else if (choice == 2) {
university.printAllPersonsRecord();
}
else if (choice == 3) {
int personChoice;
bool isInputValid = false;
while (!isInputValid) {
cout << "Kindly choose the one of the following option to provide person's details." << endl;
cout << "5 : Student" << endl;
cout << "6 : Instructor" << endl;
cin >> personChoice;
if (personChoice == 5) {
isInputValid = true;
string studentName;
bool isValidName = false;
while (!isValidName) {
cout << " Kindly enter Name of the student :" << endl;
cin >> studentName;
if (studentName.length() == 0) {
cout << " Name must not be blank. Kindly re-enter the student's name." << endl;
}
else {
isValidName = true;
}
}
int age1 = 0;
bool isValidAge1 = false;
while (!isValidAge1) {
cout << " Kindly enter age of the student :" << endl;
cin >> age1;
if (age1 < 0 || age1 > 100) {
cout << " Age must be geter than 0 or lessa then 100. Kindly re-enter the student's age." << endl;
}
else {
isValidAge1 = true;
}
}
float gpa;
bool isValidGPA = false;
while (!isValidGPA) {
cout << " Kindly enter GPA of the student :" << endl;
cin >> gpa;
if (gpa < 0.0 || gpa > 4.0) {
cout << " GPA must be geter than 0.0 or less then 4.0. Kindly re-enter the Student GPA." << endl;
isValidGPA = false;
}
else {
isValidGPA = true;
}
}
Student student;
student.setName(studentName);
student.setAge(age1);
student.setGPA(gpa);
university.persons.emplace_back(&student);
university.printAllPersonsRecord();
}
else if (personChoice == 6) {
isInputValid = true;
string instructorName;
bool isValidName = false;
while (!isValidName) {
cout << " Kindly enter Name of the instructor :" << endl;
cin >> instructorName;
if (instructorName.length() == 0) {
cout << " Name must not be blank. Kindly re-enter the instructor's name." << endl;
}
else {
isValidName = true;
}
}
float rating;
bool isValidRating = false;
while (!isValidRating) {
cout << " Kindly enter rating of the instructor :" << endl;
cin >> rating;
if (rating < 0.0 || rating > 5.5) {
cout << " rating must be geter than 0.0 or less then 5.5. Kindly re-enter the instructor rating." << endl;
isValidRating = false;
}
else {
isValidRating = true;
}
}
int age2 = 0;
bool isValidAge2 = false;
while (!isValidAge2) {
cout << " Kindly enter age of the instructor :" << endl;
cin >> age2;
if (age2 < 0 || age2 > 100) {
cout << " Age must be geter than 0 or lessa then 100. Kindly re-enter the instructor's age." << endl;
}
else {
isValidAge2 = true;
}
}
Instructor instructor;
instructor.setName(instructorName);
instructor.setAge(age2);
instructor.setRating(rating);
university.persons.emplace_back(&instructor);
}
else {
cout << "The value you entered is incorrct.Please r-enter the values." << endl;
}
}
}
else if (choice == 4) {
isValidMainChoice = true;
cout << " You are exits from system. Thanks You !!" << endl;
}
}
return 0;
};
Please modify all your code for setter
void Person::setName(string name) {
//before-edit: name = name;
this->name = name; //OR Person::name = name;
}
As the local string name parameter and your class variable are the same, you expect the parameter are passed correctly, but it doesn't.

Can anyone help me how to call this function parameter from class to be displayed in my output

This coding where I used function overloading is a code where user have to input their pointer for 4 subjects and its credit hour so it prints out their GPA. The thing is I have 3 parameter in Student(string test123, string nama, string vinto ). But I only want to display either one of the string. Lets say I want the Vinto to be print out. How can I call the vinto in my Display function so that it prints out Vinto. Heres's My coding.
CPP.cpp
#include <iostream>
#include "student.h"
using namespace std;
void main(void)
{
string nama;
string test123;
int i;
Student StudentA(test123, nama, "vinto");
cout << "key in points for 4 subject\n";
StudentA.Getpointers();
StudentA.Display(test123);
}
Student.h
#include<iostream>
#include<string>
using namespace std;
class Student
{
public:
Student(string test123, string nama, string vinto );
void Getpointers();
void Display(string name);
private:
double points[4];
int creditHours[4];
string name;
double CalculateGPA();
};
Student.cpp
#include <iostream>
#include <iomanip>
#include<string>
#include "student.h"
using namespace std;
Student::Student(string test123, string nama, string vinto)
{
name = nama;
}
void Student::Getpointers()
{
for (int i = 0; i<4; i++)
{
cout << "points for subject :" << i + 1 << endl;
cin >> points[i];
cout << "credit hour for subject " << i + 1 << endl;
cin >> creditHours[i];
}
}
void Student::Display(string name)
{
cout << "Hello " << name << endl;
cout << "Your current GPA is " << setprecision(3) << CalculateGPA() << endl;
}
double Student::CalculateGPA()
{
double totalpoints = 0;
int totalcreditHours = 0;
for (int i = 0; i<4; i++)
{
totalpoints += (points[i] * creditHours[i]);
totalcreditHours += creditHours[i];
}
return totalpoints / totalcreditHours;
}
Well, the vinto argument of your constructor is not saved anywhere, so in this example you cannot get it back. However, you could store it:
First, add a vinto field to the class:
class Student
{
public:
Student(string test123, string nama, string vinto );
void Getpointers();
void Display(string name);
private:
double points[4];
int creditHours[4];
string name;
string vinto;
double CalculateGPA();
};
Then, store the vinto argument value in this field:
Student::Student(string test123, string nama, string vinto)
{
name = nama;
this->vinto = vinto;
}
After this, you may use vinto:
void Student::Display(string name)
{
cout << "Hello " << name << endl;
cout << "Your current GPA is " << setprecision(3) << CalculateGPA() << endl;
cout << "Your vinto is " << vinto << endl;
}
Also, it's a bit strange that you store student's name in the object field, but use another name (which is passed to Student::Display) to say Hello to him.