Text Based RPG help

Started by
3 comments, last by Jonte Jinx Carrera 9 years, 3 months ago

Hi!
I've recently started making a text based RPG using different cpp and h files.
And i have been having some problems with function calls and variable calls.

I keep getting an Error LNK2019.
I just started programming so i might make alot of bad coding.
In that case, if you see something i do wrong please correct me!

Advertisement

Please don't expect people to download your entire project to debug it for you. It's rude.

When you are asking for help, it also helps to post the exact, complete error message you're getting as well (and especially with C++, make sure it's the first error, as often later errors are caused by the first error because parsing C++ is hard). In this case, the number (LNK2109) is sufficient for me to tell what the error generally is (via the documentation). But not the specifics.

What this linker error means is that you've declared the existence of some symbol (typically a function), but never defined it. Thus, when the linker goes to assemble all the separate object files complied from your C++ code, it cannot find the definition of function you're calling (or in general, the symbol you are referring to).

What is the specific unresolved external symbol the error is referring to? And where in your code have you defined it?

Like Josh Petrie said, you declared functions in a header file that were never defined elsewhere. I have enclosed 3 of your project's file code with the error fixed.

You will noticed a few things:

1. I have created the Prologue.cpp file and moved the content from Char info.cpp to it.

2. The prologue is now used as a class instead of static. See the modification i did to Main.cpp to notice it's scope remain inaffected.

3. The fonctions and member variables of the class Prologue are no longer static. Prologue.cpp now have the proper definition of thoses fonctions, and a constructor aswell.

4. The file Char info.cpp has been deleted.

Im sorry Josh!

Im quite new to this and i though it was easier for you guys to see what i did wrong!

By any means i didn't mean to be rude!

It was refering to my main function where i refered a function called ClassInfo("","");


//Game.cpp
int main()
{
    bool EXIT = 0;
    do
    {
       Prologue::NameSelect("");
       Prologue::ClassInfo("","");

and in the .h


class Prologue
{

std::string NAME = "";
std::string CLASS = "";
public:
	static void NameSelect(std::string NAME);
	static void ClassInfo(std::string CLASS,std::string NAME);

I get the NameSelect() to work, but not the ClassInfo()
And i understood by now that i haven't defined the function in the main, but im not really sure how to do it?

Thanks Sunsharior!

Ill inspect the code and see if i can understand it! haha.
I recently learned how to use Classes and header files so im not a hundred percent sure on what im doing!
I appreciate the help! really!

This topic is closed to new replies.

Advertisement