C++ C++;编译文件
我有一个名为LibItem的抽象基类和两个名为Book和DVD的继承类。我已经为这些类中的每一个创建了.h和.cpp文件 我现在想主要做一些代码来使用这些文件 目前,我只是将.h文件“包括”在主代码的顶部。 这是行不通的 我需要在使用这些文件之前编译它们吗?如果是,我该怎么做 更新 这是我的密码:C++ C++;编译文件,c++,compilation,abstract-class,C++,Compilation,Abstract Class,我有一个名为LibItem的抽象基类和两个名为Book和DVD的继承类。我已经为这些类中的每一个创建了.h和.cpp文件 我现在想主要做一些代码来使用这些文件 目前,我只是将.h文件“包括”在主代码的顶部。 这是行不通的 我需要在使用这些文件之前编译它们吗?如果是,我该怎么做 更新 这是我的密码: //--------------------------------------------------------------------------- #ifndef BookH #define
//---------------------------------------------------------------------------
#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
我收到以下错误:
[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
能否请您帮助我解决这些错误?您必须在主文件中包含所有包含要使用的声明的.h文件。此外,您必须将所有.CPP文件添加到Proj/MaMeCuff/ETC中编译,因为h文件不是编译单元……/P>一般,是的,如何取决于编译器和/或构建系统。请告诉我们使用C++ Builder的哪个构建系统或编译器。我拥有的文件是LibItem.h、LibItem.cpp、Book、h、Book.cpp、DVD.h、DVD.cppOK,我已将相关文件添加到项目中,但出现了一些错误。我更新了我的帖子,反映了这一点。