I'm working on a BST that will hold an instance of a class called Employees. My Search Tree is displaying no errors, but I'm getting quite a few from my main and Employee info files.
Every instance of emp, node, and tree are giving me the error "declaration has no storage class or type specifier." Shouldn't Employees and BSTtemplate be the type specifier?
I have been troubleshooting this last night and today, but still haven't figured out what exactly is causing all these errors.
I'm also getting errors for Employees when defining its class object and when defining the class object for BSTtemplate<Employees>.
Does anyone have any insight?
EDIT:
In main
Employees emp;
Gives me an error for emp, saying the Employees class has more than one default constructor, when it only has one. The other constructor takes a parameter.
Other errors I've got include errors for every instance of my 'this' pointer telling me 'this may only be used in a non-static member function' and every instance of operator in my overloaded operator functions telling me there are 'too few parameters for the operator function'.
I also get errors on empName and idNum telling me they're inaccessible, but they're listed as private to the class, meaning the functions should be able to access them, shouldn't they?
EDIT:
I also included BSTtemplate<Employees> as a friend class, but either I implemented it incorrectly, or making it a friend hasn't solved anything like I thought it might.
I meant the error messages given by the compiler.
Example
1 2 3 4 5
int main()
{
x = 3;
return 0;
}
Errors given:
C:\myProgrammingProjects\main.cpp||In function 'int main()':|
C:\myProgrammingProjects\main.cpp|82|error: 'x' was not declared in this scope|
||=== Build finished: 1 errors, 1 warnings ===|
I am using code blocks where the procedure for copying the error codes is to right click in the error message window and select "copy contents to clipboard".
You can't give default values for both arguments here:Employees(int id = 0, char* n = "N/A")! Why are you assigning values to id and n in the constructor?
This would overwrite any values passed.
I think you might be right, but here's what I get from my error in the output window(I've redacted my name from the files, because I'm paranoid like that):
c:\users\\desktop\assignment8_adv. c++\assignment8_adv. c++\main.cpp(38): fatal error C1075: end of file found before the left brace '{' at 'c:\users\\desktop\assignment8_adv. c++\assignment8_adv. c++\bsttemplate.h(129)' was matched
So it seems my biggest problem (at the moment) is the compiler detecting the end of file before the first brace in main.
EDIT:
Okay, I've managed to weed out A LOT of the errors (most of which were caused by a single misplaced bracket), but I still have a few left to deal with.
The error was indeed in my BST template. I'm notorious for losing track of my brackets, unfortunately.
I'm having an entirely separate problem now, though. Unresolved externals, again to do with the default constructor and destructor in Employees.
main.obj : error LNK2019: unresolved external symbol "public: __thiscall Employees::~Employees(void)" (??1Employees@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Employees::Employees(void)" (??0Employees@@QAE@XZ) referenced in function _main
I've built classes with a default constructor and a constructor like the one above before(I actually just looked back at an old assignment to make sure I hadn't mucked up something really basic), so I'm not understanding why this program is still giving me unhandled exceptions.
I really appreciate all the help thus far, I'm just not really seeing where I'm going wrong.
Unhandled exceptions? So now that it builds, it crashes?
Bummer!
EDIT: To clarify regarding the constructor issue.
You can have this: Employees();
or this: Employees(int id = 0, string n = "N/A")
but not both. Why? Because they can both be called like this: Employees(). Perhaps in your previous project you did not have both.
Those linker errors you gave last are probably due to not giving definitions for Employees() and ~Employees().