繁体   English   中英

C ++编译文件

[英]C++ compiling files

我有一个名为LibItem的抽象基类,还有两个名为Book和DVD的继承类。 我为每个这些类制作了.h和.cpp文件。

我现在想在main中做一些代码来使用这些文件。

目前,我只是在主代码顶部“包含” .h文件。 这是行不通的。

使用它们之前我需要编译这些文件吗? 如果是这样,我该怎么做?

更新

这是我的代码:

//---------------------------------------------------------------------------

#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

我可以帮忙解决这些错误吗?

您必须包括all.h文件,该文件包含要在主文件中使用的声明。 另外,您必须将所有.cpp文件添加到project / makefile / etc中进行编译,因为.h文件不是编译单元...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM