using ::bb::cascades::Application;
#include <bb/cascades/Application>
What do these two declaration mean?
And are there any good tutorials which states the using directive/declaration deeply?Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
#includeis a prepocessor directive. It basically tells the prepocessor to take the given file and replace the#includeline with the files content.usingon the other hand makes it possible to use names inside anamespace(structs, enums, functions) without thenamespaceprefix. In this case::bb::cascades::Applicationwill enable you to use writeinstead of
if
::bb::cascades::Applicationis a default-constructible class.“Why do I ever need to use
#include?”In order to use a function or to create an object the compiler must know the structure of this things, for example the functions signature or the member and methods of a class. These things are written in header files. Lets have a look at a very simple example, where we provide some module (called
module):The module
moduleAs you can see our
moduleconsists of a struct with a member and a method, and a simple function. Note that we wrap everything up in the namespacemodule. Now we have another program which wants to usemodule:And this won’t work, because the compiler doesn’t know about both the namespace
module. You need to add the declaration, which can be done by using#include(see first paragraph of this answer):Note that you’ll need to compile both module.cpp and main.cpp, otherwise you’ll get linker errors.