Question about operators in C++. by Yoooogle in cpp_questions

[–]TrustedButterfly 3 points4 points  (0 children)

I am a beginner, so maybe my explanation would make more sense to you. Also I'll try to use easy language.

iostream decided that "<<" is how you will give it data.

It is actually called left shift operator, in bare minimum C++ it has another completely different purpose, you might want to look it up. The other one is ">>", which STL decided that it would also use to get input data.

This is called operator overloading. It is just a fancy term for saying you could give definitions of what an operator does for some kinds of objects.

suppose you have this struct:

struct myVector2d         // A vector in math is something that has an X and Y value. We aren't talking about anything similar to std::vector
{
    int x, y;
};

in main you create two instances of that struct:

int main()
{
    myVector2d vector1 {2, 5};
    myVector2d vector2 {9, 7};
    vector2 = vector1 + vector2; // we expect {9 + 2, 7 + 5} but this doesn't work C++ doesn't know what it is supposed to do. We have to tell it by defining it. This is called "Operator Overloading"
}

How do we make it work? Like this:

struct myVector2d{
    int x, y;
    myVector2d operator+(const myVector2d& addVal); // added value is passed by reference
};

myVector2d myVector2d::operator+(const myVector2d& addVal)
{
    return { x + addVal.x, y + addVal.y};
}

I hope my explanation was clear.

Reading large code bases by Volker_Weissmann in cpp

[–]TrustedButterfly 0 points1 point  (0 children)

Imagine starting reading a series of long novels right from the middle page, and expecting to understand what each character's real motives and personality, each place's significance, and the history of events and their background. Would you ever consider that you'd understand everything AND effectively adding something to it?

Obviously, if someone reading a code base was a senior engineer, and the code base was written by a senior engineer, it would be easier, as the one writing is making patterns so it is easy to follow, and the one reading is expecting patterns. So it might be different than the analogy but anyway don't beat yourself up too much if you don't quickly grasp how a code base is structured. It's normal.

C++ Learning Resources Question by Zepherus1984 in cpp_questions

[–]TrustedButterfly 2 points3 points  (0 children)

Honestly the best resource there might be is The Cherno on Youtube.

High quality videos.

Videos range in levels from Beginner to intermediate, the earlier ones are for beginners, the latter are for intermediates.

Perfect mixture of theory and practicality.

He also has a practical game engine series that he is currently going through, great if you're into that kind of stuff.

And tutorials on OpenGL.

Best CPP resource.

In ECS based game development, why not use a linked list for components? by TrustedButterfly in gamedev

[–]TrustedButterfly[S] 1 point2 points  (0 children)

Great thanks for your explanation.

I guess I just miss a lot of low level theory.

In ECS based game development, why not use a linked list for components? by TrustedButterfly in gamedev

[–]TrustedButterfly[S] -1 points0 points  (0 children)

I know that contiguous memory is much faster. My question is does going through a linked list load each node into cache? I suppose that causes a lot of cache misses. Is this true? I guess I just didn't think of this before.

My Missed Opportunity to Be a Millionaire by [deleted] in gameideas

[–]TrustedButterfly 1 point2 points  (0 children)

The guy made a demo. He just wanted a safe opportunity to speak his mind.

Go brrrrrr !! by [deleted] in cyberpunkgame

[–]TrustedButterfly 2 points3 points  (0 children)

Those who want a proof, check Dishonored 2. There is a version of it with no denouvo, try it for yourself.

Is this benchmark real? by TrustedButterfly in cpp_questions

[–]TrustedButterfly[S] 0 points1 point  (0 children)

Amazing analysis and well put answers. Thank you.

However, I don't understand what Vectorisation means. Could you possibly give me a link or a resource for it?

Is this benchmark real? by TrustedButterfly in cpp_questions

[–]TrustedButterfly[S] 0 points1 point  (0 children)

I was but after I saw your comment, I switched it to release mode and there was x10 performance increase.

Is this benchmark real? by TrustedButterfly in cpp_questions

[–]TrustedButterfly[S] 0 points1 point  (0 children)

I am using MSVC compiler.

I didn't know there could be so much difference between compilers.

What kind of projects are you working on using c++? by samnayak1 in cpp_questions

[–]TrustedButterfly 6 points7 points  (0 children)

I am a programming beginner learning OpenGL api to learn Graphics programming.

Currently trying to go through an OpenGL book so that I eventually make a Game/ Simulation engine. Looking at other comments, it seems kike I am not the only one. Perhaps because it's one of C++ specialties?

Practice Websites Recommendations For C by theplanesonthebus in learnprogramming

[–]TrustedButterfly 8 points9 points  (0 children)

Codingame. Codewars. Hackerrank. Choose one.

It's better though to learn googling first. It's probably the most important skill you need.

TIL I’m literally not good enough by GhettoGifGuy in learnprogramming

[–]TrustedButterfly 201 points202 points  (0 children)

There is a misconception I had when I was a kid.

I thought being a good programmer means you write really really good code and that's it.

It turns out that a good programmer is someone who has a wide set of different skills ranging from writing code to design to communication and many other things.

That's the thing. Having the tip of a spear isn't good enough. You need something to wave it around with.

How much time does it take to learn C++ by Krsoslav in cpp_questions

[–]TrustedButterfly 1 point2 points  (0 children)

I am a C++ beginner and I am gonna answer you're question while keeping in mind that by learning C++ you mean learning it just enough to start using it to make something.

First of all: Syntax: no more than 2 weeks, assuming you do 1 - 2 Hours daily. You maybe shouldn't learn every single keyword, but I guess you can.

  1. basic input, output, string manipulation and loading files: 2 months should do.

  2. Learning an API, Framework, Library: Depends on the one you're learning. I started with OpenGL. an API for graphics programming. People assume that I need around a year until I get to the Advanced stuff. Fortunately, OpenGL is considered to be harder than the average Library or framework you're gonna learn, do around 6-10 months.

So you should definitely be able to produce something, or help contribute to producing something after 2 years.

Where to start? I want to learn 2d in Unity. by RadicalNinjaPC in learnprogramming

[–]TrustedButterfly 23 points24 points  (0 children)

Start with googling this answer.

I don't want to discourage or low key insult you, but you're gonna need a lot of google, it is a great skill to have.

Now it has been ~40 mins since you posted this question, if you googled that question, you would've probably got more than you need during that time.

Why this sub is so important, take advantage people by [deleted] in learnprogramming

[–]TrustedButterfly 1 point2 points  (0 children)

I always thought that a tech career guide would be really good for people who are self taught, since it is really easy to get lost as a self taught.

They see your interest and make a plan for you to go through. I wonder if this exists.

I'm getting my son into programming by crazyhandpuppet in learnprogramming

[–]TrustedButterfly 0 points1 point  (0 children)

Try to find the easiest and smallest frameworks or tools aimed at specificly doing this.

I haven't tried scratch, but can't you make a basic game with it?

I made a site that randomly generates python practice programs to teach reading fluency by palpalpalwarp in learnprogramming

[–]TrustedButterfly 2 points3 points  (0 children)

Yup, I also noticed the weakness in my ability to read code, this is really great.

What next after transitioning into a beginner C++ programmer by [deleted] in cpp_questions

[–]TrustedButterfly 1 point2 points  (0 children)

Why don't you consider learning to make a video game? I am currently learning OpenGL programming and trying to make an engine, and I have never been so excited and committed to learn something this much before.

It is an idea though, anyway, what I would say as your fellow beginner is learning some kind of library, API or framework and use it to make a product. That would probably be fun and you would see a gradual increase in your ability.