The c++ declaration is placed in the a.h file, and the implementation is placed in a.cpp. Why can the class implemented in a.cpp be used by referencing a.h in main.cpp?
为情所困
为情所困 2017-05-31 10:39:52
0
2
853

Use visual studio to write a c program. The c declaration is placed in the a.h file, and the implementation is placed in a.cpp. Why can you use the class implemented in a.cpp by referencing a.h in main.cpp, while referencing a.cpp An error will be reported.
I don’t understand the rules very well. Can someone explain it to me?

为情所困
为情所困

reply all(2)
PHPzhong

First of all, the former means that you want to use this class. Considering that during the compilation process, you can use this class and function as long as there is a declaration of the class and function. When linking, the linker will look for the definition of the class and function in other files. In the latter, you do not have a declaration of the class implemented by a.cpp. The compiler does not know this class, so a compilation error occurs.

世界只因有你

It’s written more clearly here, you can understand it
http://blog.csdn.net/praker/a...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!