Insert one program into another

Hello,

Newbie C++ programer with an question. I have a dice roller program that I want to use in different program and I know there is a better way to add than copy and paste all of the code, but dont know how. Can I attached it as a file and call the file in my main program?

Thanks for the help.
You have inadvertently discovered why libraries are useful. You can compile your dice roller as a library file and then link to it in each of your other programs. You may need to adjust the design of your code so that it is not specific to any particular program.
When writing code, make it as modular, independant and as reusable as possible. This can then be considered as a library.
Topic archived. No new replies allowed.