As you can see I have no idea what I'm doing. I'm taking lines of code of random websites and pasting them into my program, then when it doesn't compile I move parts around so that stuff is (I hope) in the scope it's meant to be in. This is the technique I used to learn Blitz Max, and it works, because I can use Blitz today and instantly make a program which uses OOP, even though I haven't used Blitz since 2006
This is not a method I would recommend to learn any language, least of all C++ where a lot of things can "appear to work" very easily while blowing up in your face later (sometimes much later, as in weeks or months).
Your problems are not really related to OOP though but essential bits of the language, like scoping.
This might be actually a disservice to you, but:
Thing(int a, int b)
ThingRec.x = x;
ThingRec.y = y;
ThingRec.w = (x + 32);
ThingRec.h = (y + 32);
void drawMe(SDL_Surface* pic, SDL_Surface* vid) const
SDL_BlitSurface(pic, 0, vid, &ThingRec);
int main(int argc, char* argv)
for (const Thing& thing : myList)
thing.drawMe(/* whatever */);
On a sidenote, when I see "using namespace std;" in a file I have the urgent need to punch the author.
Edit: Mhm. Apparently the darn forum editor does not even allow me to preserve spaces anymore. Apparently not a week can go by without it becoming ever slightly more broken...
Yes, I suspect that "abstract class" is a term one uses when there is an abstract class, with inheritance used for sub-classes - hence, the original class (not actually used directly) is called the abstract class. I'll edit my file now and add the proper terms
You suspect wrongly. An abstract class is a class which contains one or more pure virtual member functions. An abstract class cannot be instantiated because the compile prevents you from doing that. A lot of base classes are not abstract even when they are seldom or never intended to be instantiated.
One of the reasons Yegor mentions is the dependency of clients connected to the object. Say, we suddenly want to know who withdrawn something from the object? I am not understanding why his "idea" would help us in any way. We still have to change the withdraw method and all clients using this withdraw method need to be changed. I guess I still have no clue what he is talking about.
If you can only withdraw money by calling 'withdraw' you can just add a new parameter to withdraw and your compiler will scream at you until all places where money is withdrawn supply that information. If you just manually decreased amount everywhere you have to find all uses of 'amount' manually in the code, identify which are actually withdraw operations and add the withdrawer information manually (help the compiler can be to you in that case: zero).
This eventually results in long constructors since all the final properties that are allowed to mutate (yes it sounds crazy) need to be set in the constructor.
If your constructor becomes so complicated you have to pass so many parameters you probably have a class which just tries to do far too much. Look into the Single Responsibility Principle (https://en.wikipedia.org/wiki/Single_responsibility_principle). Having immutable classes where reasonably possible certainly simplifies a lot of problems, but especially in the context of game programming it is not always doable. Spending a few moment to ponder "Do I actually need that to be mutable?" for a new class is not a bad idea though.
I'm not familiar with SDL but my guess would be these errors have nothing to do with SDL but originate in whatever framework your book supplies, probably because utility code it expects is not compiled/linked together.
There is no library which could provide this information. You could only get that functionality with a custom preprocessing step before passing the source to the compiler (which would be just a hand-rolled kind preprocessor definition again).
Well, SDL 2.0 has been out for a long while now and although I have never used it from what I have heard it's much better than its predecessor. You cannot really expect deprecated stuff to remain around indefinitely.
Also, I now have the strong suspicion your unresolved externals have a very different source than linking or not linking SDL mixer. Most likely it depends on some Windows multimedia functions which you have to link as well. Of course that would have been immediately obvious had you posted the actual error messages. Which you unfortunately did not.
On a personal note, this is the second time you go towards blaming the tool in this thread. A decent programmer does not blame the tool until he has understood the whole problem and exhausted all options. Placing the blame on the tool early and often is a good way to tick people off and receive less and less help in the future.
I've had mixer.dll in the project folder the whole time. I added SDL_mixer.lib to sdl's LIB&nbsp;directory and I&nbsp;tell Visual Studio to include it as an additional dependency and it still gives 76 errors.
Are you telling MSVC to actually link it or have you just specified it as a dependency?
It tells me to use /nodefaultlib:library but what the heck is that? Do I replace the words "library" or do I input that parameter verbatim? I don't understand how the compiler complains about one thing, then I add what it wants, and it gives 77 warnings. It's so stupid! I have sympathy for people who try programming and give up. The errors make no sense. Before anybody asks, yes I can reproduce this problem over-and-over again. I want to know how to fix it.
I guess this error has something to do with Microsoft's stupidity in making Visual Studio. I think maybe I can kill off msvcrt.lib and there will be no conflict. Should I do it?
A library you are trying to link was compiled with a different MSVC runtime than the one the rest of your project is using. This could be a different version or a conflict between dynamic/static or debug/release runtimes. You need to download a version which matches your build system or build it yourself using the adequate compile time options.
Unless you absolutely know you will only ever be using MSVC I would not do something like that. Both at work and at home I'm using CMake for that. The tool which does these transformations is a simple command line application inside the project. CMake tracks the dependencies, builds the tool before anything needing the transformations and executes it as part of the build process. It's CMake's job to put that into a form your build environment understands, whether that is MSVC project files, a bunch of make files or soemthing else.
In my opinion the console is irrelevant. Check the content of your strings with the debugger, not by printing them to the console. The console expects some encoding, perhaps Latin-1 (which works fine the range 1-127 but not beyond) or ANSI and whatever encoding your compiler generates is probably not the same.
For example when I print "Test 'ü'" to the console in a source written in stock QtCreator and compiled with MinGW I get "Test 'Ã¼'" printed out. The debugger says the same and the values of the relevant bytes are a 195 followed by a 188. Now, I could take a look at how UTF-8 was encoded again and do the check myself. However, it's been a long day and I'd rather use this cheat sheet but it confirms I'm dealing with UTF-8.
Now, we are not even sure what the encoding of the string is in your source file. If you wrote it with MSVC it does something, but not the sensible. Open your source with a decent text editor (like Notepad++) and convert it to UTF-8 (with the BOM - the BOM is not recommended but MSVC does not recognize UTF-8 properly without it).
Now, dealing with UTF-8 is not the simplest thing since multiple bytes can be used for a single character. Still, I strongly recommend it for sanity, and I say that as someone who has written applications which translate freely between German, English and Italian (sometimes other languages). For a simple game with extremely limited text output it might not be worth the battle but the battle is won and lost at string encodings no matter how exactly you solve the issue. You absolutely need to know in which way your input strings are encoded and which mapping the font uses.
Of course. Unfortunately you do not post anything that would allow anyone to help you. You know, simple things. Like the code you are having problems with together with the error message. Crystalball-based forum posts usually do not work out well.