[QT] qt_begin_namespace In the QT header file (what is the class name used in the QT header file)

Source: Internet
Author: User

During header file writing

There are some class qfile and other things that seem to be declared... for example below

# Ifndef window_h
# Define window_h

Qt_begin_namespace
Class qtcpserver;
Class qtcpsocket;
Class qprogressbar;
Class qlabel;
Class qdialogbuttonbox;
Class qfile;
Qt_end_namespace
// Code end

Class qaction;
Class qcheckbox;
...

If no declaration is made, an error similar to the following will occur.

Iso c ++ forbids declaration of 'qfile' with no type

So what is this ????


This is because only the pointer declarations of these classes are in the header file and are not actually instantiated. In the CPP file corresponding to this header file
# Include <
Qdialogbuttonbox
>
# Include <
Qfile
>
...

These classes will be instantiated in the CPP file.
It is directly in the header file # include <

Qdialogbuttonbox>
# Include <

Qfile> It is also possible, like this, it seems that it can reduce the relevance of each file during compilation and will not introduce
The re-Compilation of a large number of other files makes no difference when doing small projects, but it takes several hours to compile the files. The advantage of this is obvious.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.