Objects are not being read properly?

Hello, I copy-pasted the code from BC18, which is the lecture after “using_getter_methods” because my old code was also giving me an error of: LNK2019

For one of the Objects, it said this:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol “public: int __thiscall FBullCowGame::GetCurrentTry(void)” (?GetCurrentTry@FBullCowGame@@QAEHXZ) referenced in function “class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl GetGuess(void)” (?GetGuess@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) BULLCOWGAME!! C:\Users\Stephen\Desktop\BULLCOWGAME!!\BULLCOWGAME!!\main.obj 1

I have his code exactly as It is on this: https://github.com/UnrealCourse/02_BullCowGame/commit/6111258f3dd5d49b537ece2bdcdede663072a99f

and attached below is my code:

Thanks for your help!

I can definetly tell you that you haven’t closed curly braces on IsGameWon() function declaration. Try that and then tell me does it helped.

This error usually tells you that there is something in your code that you referenced but compiler cannot find. The error you’ve copy-pasted here tell you specifically that it can’t find function GetCurrentTry() that is invoked inside GetGuess() function.

So it’s always good to look at your includes at this point.

Your files are named Fbullcowgame.cpp and Fbullcowgame.h but your #include is referencing file called FBullCowGame.h which does not exists. Thats probably why you’re getting unresolved symbols.

In programming languages naming is always very important. And most of the stuff here is case sensitive. Thats why professional developers are using conventions and tools that enforce them. For example if you’re using UpperCamelCase for your class names then you should always use UpperCamelCase for classes inside your project. You should always choose how you want to name different things in your code and stick to it.

Keep in mind that similar error can be caused by misplacing braces as well. That’s why you need to always stick to one convention of formatting braces as well.

Hello, im unsure what you mean by this? What do you mean that it does not exist, and how can I solve this?

Also ive fixed the curly brace but I was still getting the same errors.

I mean that there is a mismatch in what you’ve typed into include and what you really have.

Here i can see how your files are named:
Names

You’ve created two files Fbullcowgame.cpp and Fbullcowgame.h.

And here, inside main.cpp and Fbullcowgame.cpp

Include

You’re including file named FBullCowGame.h. And there is no file with that name inside your solution.

And when I was taking these screenshots I’ve also noticed that it doesn’t look like you have these files even added into your project. Make sure they are present inside the folder with your project. It should have look similar to this:

projectstructure

Good luck!

I decided to just wipe the old header file and create a new .h header file, named the same thing and is the correct spelling. My folder looks somewhat like yours now.

Now, I am unable to build or build and run it. It doesnt give me the prompt

Thanks for your help so far.

Could you just zip your project, and post it then? I’ll look at it then.

Here it is:

ZIPPEDBULLCOWGAME!!.zip (206.0 KB)

Thanks again

Ok so basically you still havent repaired the problems with your files.

I’ll explain you what you’ve did wrong, but basically I don’t think you understand how project files (.h and .cpp) work, so what I’d do on your place is to read about .h and .cpp files.

You should also really take a step back, - it’s not bad to do this sometimes - remove everything up unil lesson 27 (https://www.udemy.com/unrealcourse/learn/v4/t/lecture/4302952?start=0) and do it again like it was shown in the movie.

If you don’t get good grasp about these basics then you’ll have troubles in the future, trust me.

Basically first of all you need to be really aware about how you’re naming things. Big letters, small letters, extensions etc. This is really important.

File BullAndCowGame.cpp is different file from BullAndCowGame - Copy.cpp and BullAndCowGame.h or even bullandcowgame.cpp

So the first mistake I saw when I’ve opened your project is that you don’t really have Fbullcowgame.h

Files

See - you have Fbullcowgame.cpp and Fbullcowgame - Copy.cpp. As I’ve said in my previous posts this is not what you’re including in your files.

Inside your main.cpp there is:

See you’re looking for (line #3) #include "Fbullcowgame.h". This file doesn’t exists. If you go back to the tutorial videos then the one that I’ve linked and the next one are showing how to create this file.

Second problem is that you haven’t even added these files to the Visual Studio project.

Przechwytywanie

See? You have main.cpp - thats good, but you don’t even have the file Fbullcowgame.cpp. You’re referencing some file called bullcowgameher.h which doesn’t even exists. I suppose this is the file you’ve craeted when you were following tutorial lessons.

I can figure out that your problem originally was because you named your file bullcowgameher.h and later you have typed your code exactly like it was in tutorial videos so you were trying to include FBullCowGame.h. Then you started copy-pasting code from github, removing files and adding new ones directly in explorer which really made a big mess.

What you should to now is deleting both Fbullcowgame.cpp and Fbullcowgame - Copy.cpp from your project folder and deleting reference to bullcowgameher.h from Visual Studio and going again through the videos about header files, but this time really paing attenion to naming things.

Also you shouldn’t name your project BULLCOWGAME!! - this is very bad practise to have anything else in your project or filenames than letters and eventually numbers.

What I also recommend for you is to do some more reading about what .h and .cpp files really are and what they do in C++.

If you do this stuff, then you should be able to repair your project really easy.

Thank you so much for that!

I think Ill go over the video with how to do classes again, just for clarity and to make sure I can do it.

Privacy & Terms