I have an abstract base class called LibItem, and two inherited classes called Book and DVD. I have made the .h and .cpp files for each of these classes.
I am now wanting to do some code in main to use these files.
Currently, I am just ‘including’ the .h files at the top of my main code.
This is not working.
Do I need to compile these files before using them? If so, how do I do this?
UPDATE
Here is my code:
//---------------------------------------------------------------------------
#ifndef BookH
#define BookH
class Book : public LibItem
{
public:
Book(const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, const std::string&);
void setISBN(const std::string&);
std::string getISBN();
void PrintDetails();
private:
Book();
std::string ISBN;
};
//---------------------------------------------------------------------------
#endif
I am getting the following errors:
[BCC32 Error] Book.h(7): E2303 Type name expected
[BCC32 Error] Book.h(9): E2090 Qualifier 'std' is not a class or namespace name
[BCC32 Error] Book.h(9): E2293 ) expected
[BCC32 Error] Book.h(10): E2090 Qualifier 'std' is not a class or namespace name
Can I please have some help with these errors?
You have to include all.h files which contains declaration you want to use in your main file. Also, you have to add all .cpp files to your project/makefile/etc to compile it, because .h files aren’t compilation units…