c++ - Is it possible to have more than 1 .cpp file in a project (souce folder)? If so how would the .cpp file communicate? -


so, working c++. know how link .h file .cpp (pretty simple stuff.) problem having that, don't want write code in 1 .cpp file, makes big , organization becomes hustle. in other languages (c# , python) able write class in different file derive children it, header file in c++, .h files used declaration of functions , .cpp being coded. so, without having 1 large .cpp file, can code in multiple .cpp files?

sure. have 1 header file relevant declarations , can have multiple source files implementing them. need make sure linked together.

it possible, because when link them together, doesn't matter translation unit definitions come from, thing matters exist. there no difference if have implemented them in same translation unit.

it this:

// header.h // guards... void func1(); void func2();  // source1.cpp #include "header.h" void func1() {}  // source2.cpp #include "header.h" void func2() {} 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -