I'm making a text game for my players in DND right now, and I can't figure out why I'm getting the error: multiple definitions of functions.cpp
I'm running it with onlinegdb.com right now, but it works with Ubuntu 18.04
#include<iostream>
#include<string>
usingnamespace std;
void printInfo()
{
cout << "Welcome to Ryxaar's Dungeon Delver! Pick your class: " << endl;
cout << "1. Fighter, Close range jack of all trades\n";
cout << "2. Wizard, High damage but low defense, magical expert\n";
cout << "3. Ranger, Medium range sustained damage, ranged weapons expert" << endl;
}
The way you have it, it will "work" if you only compile the main file. But if you also try to compile the other (and link it with the first file) you'll get the multiple definition.
The problem is that you don't have a header file. Instead you've just "included" the source file. You're supposed t create a header file for the cpp file that provides the information needed to use the functions/etc. in it and include that in the main file. Then compile the source files separately and link them.