+ 2

What advantage or disadvantage of writing program in 3 file structure in c++ than writing program in 1 file in c++?

I would like to know what will be the difference if i write a program using 3 file structure in c++.i am beginner in c++.

21st Jan 2017, 5:12 AM
Sa'ad Patel
Sa'ad Patel - avatar
6 Respuestas
+ 4
Large projects can contain thousands if not millions of lines of code. seperating classes into files helps make managing the code base much easier. But as Jason stated. It makes no difference to the final program
21st Jan 2017, 5:51 AM
jay
jay - avatar
+ 3
the main advantage of using different files for different classes is that you can edit individual classes without having to touch the main operating files. Ultimately it doesnt make a difference to the final executable.
21st Jan 2017, 5:45 AM
Jason Hoffman
Jason Hoffman - avatar
+ 3
well. there is main.cpp which is the entry point of the program. when you create a class (lets say we are making a class called animal) you seperate the definition and methods into seperate files a .h header file (animal.h) and a .cpp file (animal.cpp) animal.h would contain something like this class animal() { public: animal(); void speak(); private: string m_name; } animal.cpp would look something like this #include "animal.h" animal::animal(): name("fred") { } void animal::speak() { cout << "I am " << m_name; }
21st Jan 2017, 6:54 AM
jay
jay - avatar
+ 1
Further explaination is appreciated
21st Jan 2017, 6:33 AM
Sa'ad Patel
Sa'ad Patel - avatar
0
Thanks i was thinking it will take less time to execute when the program is written in 3 file structure.
21st Jan 2017, 5:51 AM
Sa'ad Patel
Sa'ad Patel - avatar
0
Thanks my confusion is clear... Thanks again.
21st Jan 2017, 5:52 AM
Sa'ad Patel
Sa'ad Patel - avatar