'Out-of-line definition does not match any declaration
I am stuck with an error I don't understand. I have declared Student and coded the following string.
Below is my code, the error happens at:
Student::Student(string studentID, string firstName, string lastName etc...
Student::Student(string studentID, string firstName, string lastName, string emailAddress, int age, DegreeProgram degreeProgram, int daysInCourse[])
{
studentID = studentID;
firstName = firstName;
lastName = lastName;
emailAddress = emailAddress;
age = 46;
degreeProgram = degreeProgram;
for (int index = 0; index < daysToCompleteArraySize; index++) {
daysInCourse[index] = daysInCourse[index];
}
Below is the .hpp file:
#include "degree.hpp"
#include <string>
#pragma once
using std::string;
class Student {
public:
// Constructor
Student(string studentID, string firstName, string lastName, string emailAddress, int age, DegreeProgram degree, std::vector<int> daysInCourse[]);
Student();
public:const static int daysToCompleteArraySize = 3;
private:
string studentID;
string firstName;
string lastName;
string emailAddress;
int age;
DegreeProgram degreeProgram;
int daysInCourse[daysToCompleteArraySize];
Solution 1:[1]
Well this is doesnt match
Student::Student(string studentID, string firstName, string lastName, string emailAddress, int age, DegreeProgram degreeProgram, int daysInCourse[])
Student(string studentID, string firstName, string lastName, string emailAddress, int age, DegreeProgram degree, std::vector<int> daysInCourse[]);
and that second one is very odd, std::vector<int> daysInCourse[]
You probably mean
Student::Student(string studentID, string firstName, string lastName, string emailAddress, int age, DegreeProgram degreeProgram, std::vector<int> daysInCourse)
Student(string studentID, string firstName, string lastName, string emailAddress, int age, DegreeProgram degree, std::vector<int> daysInCourse);
or even better
Student::Student(string studentID, string firstName, string lastName, string emailAddress, int age, DegreeProgram degreeProgram, std::vector<int> &daysInCourse)
Student(string studentID, string firstName, string lastName, string emailAddress, int age, DegreeProgram degree, std::vector<int> &daysInCourse);
I suspect somebody told you to use std::vector instead of a raw array but you did not complete the edit.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | pm100 |
