I'm getting some errors with my code, & cant seem to find where the problems are.
Basically I'm making a student class that calls out the student id & name.
I hope someone can point me in the righ direction to get this code working.
Thank you
student.cpp:
#include <iostream>
#include <string>
#include "Student.h"
using namespace std;
// cconstructor for your class
Student::Student()
{
// code to do any initialization needed for a new object instance
//myPrivateInteger = 0;
}
Student::Student(int ID, string Name)
{
ID = newid;
Name = newname;
}
// destructor for your class
Student::~Student()
{
// code to do any clean up or checking needed when an
// object is destroyed
// free any memory allocated by this class
}
int Student::getStudentID()
{
return ID;
}
string Student::getStudentName()
{
return Name;
}
void Student::setStudentName(string newname)
{
Name=newname;
}
void Student::setStudentID(int newid)
{
ID = newid;
}
void Student::display()
{
cout << "Name: ">> Name;
cout << endl;
cout << "ID: " >> ID;
cout << endl;
}
Student.h:
#include <iostream>
#include <string>
using namespace std;
#ifndef STUDENT_H
#define STUDENT_H
class Student
{
public:
// constructor
Student();
Student(int, string);
// destructor
~Student();
string getStudentName();
int getStudentID();
void setStudentName(string newName);
void setStudentID(int newID);
void display();
private:
int newid;
string newname;
};
#endif
driver.cpp
#include "Student.h"
int main()
{
Student student;
student.setStudentID("1234");
student.setStudentName("tom");
student.display();
return 0;
}
the errors are
error C2664: 'Student::setStudentID' : cannot convert parameter 1 from 'const char [8]' to 'int'
error C2065: 'ID' : undeclared identifier
error C2065: 'Name' : undeclared identifier
error C2065: 'Name' : undeclared identifier
error C2065: 'ID' : undeclared identifier
error C2065: 'Name' : undeclared identifier
error C2065: 'ID' : undeclared identifier