I get the following two errors:
"constructors not allowed a return type"
"Student followed by int is illegal, did you forget a ';' "
I got these errors before and the code is extremely simple. If I remark the constructor, it stops at the other constructor as well. There is no return type of the constructor. The only way I could fix it previously was to delete the project and then recreate it, and overlay another project's code as a template. I would then modify it back to the code it is supposed to be. The error then seems to go away and I have no idea why it works when the resulting code seems to be exactly the same as the one that did not work. It seems to be a mystery. I started a CLASS and everything was fine until I added another class implementation file.
Partial code below:
Code:
(Student.h file)
Public:
Student(); // constructor
Student (char *, char *, char *);
(Student.cpp: Implementation)
#include <iostream>
using namespace std;
#include "Student.h"
Student::Student () { } //"constructors not allowed a return type" error stops here
// There is obviously no return type!
Student::Student (char* first, char* last, char* street)
{
...... // if above remarked out, compilation stops here....
}
(school.cpp: Driver)
#include <iostream>
using namespace std;
include "Student.h"
// "Student followed by int is illegal, did you forget a ';' "
// Error points to this location
// Semicolon not needed on line above!
int main ()
{
return 0;
}