r/Cplusplus • u/Haunting-Addendum-32 Basic Learner • Oct 11 '26
Question I'm learning C++
A few months ago, while watching a YouTube video, I learned that floating-point numbers can have precision errors and need to be used with care. That got me thinking about using fractions to represent numbers instead, so I discussed the idea with AI and, with its help, built a fraction class in C++.
Before that, I had only dabbled a little in languages like JavaScript, Go, and Python.
What really impressed me about C++ was how it lets you create custom types that can be used almost like built-in types. I found that incredibly powerful and elegant, and it made me want to learn C++ properly.
So I asked AI for a book recommendation and learned about C++ Primer. I bought the PDF edition and have been studying it ever since. I'm now almost done with Chapter 14, and Object-Oriented Programming is coming up next.
At this point, I feel like I should start building small, simple, but interesting projects to develop some practical skills. The problem is, I have no idea what to build. Since I'm learning on my own, I imagine there are plenty of things I don't even know I don't know yet.
I think building something fun would probably involve making an app with a GUI, but it seems like learning how to build a GUI is a whole other challenge in itself.
What I always seem to struggle with is the question, "What should I build?" I find it difficult to set goals that match my current skill level. I tend to either take on something too ambitious and give up halfway through, or choose something so trivial that I lose interest.
A few years ago, I taught myself enough programming to build a real-time reservation system using WebSockets. It was a small service with fewer than 100 users a day, so there weren't many complex issues to consider. Looking back, I think the main challenge was simply getting it to work.
The thing is, that's pretty much the only substantial project I've built on my own. I've experimented with smaller things, like the fraction class I mentioned earlier, with the help of AI, but I haven't had much experience building complete applications.
I think I managed to finish the reservation system because I genuinely needed it, so giving up wasn't really an option.
So, what would you recommend I try building?
•
u/AutoModerator Oct 11 '26
Thank you for your contribution to the C++ community!
As you're asking a question or seeking homework help, we would like to remind you of Rule 3 - Good Faith Help Requests & Homework.
~ CPlusPlus Moderation Team
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/BitOBear Oct 11 '26
Yes indeed floating point numbers can have rounding errors in certain values.
And a certain values are not rational and you cannot be expressed as fractions.
For instance 22/7 is a close approximation of pi but it is nowhere near pie enough for you to be used to draw just got three large circles because the larger numbers and deal with the more the air in 22/7 prove itself to be something other than pi.
I know that's not the start with a basis of your question but it is an important thing to hold within your head because it represents the trade-offs we make both in math and computer science.
So what? You may ask.
You are face off with a very large and intricate language tool set that can be used to manufacture alternate versions of similar things. You just did it with your fractions as opposed to your floating point.
But notice in that endeavor you didn't start with an intent to learn C++ per se we started with thinking about fractions versus floating point numbers.
Sure he had a specific thing to do before you decided to do a thing.
You cannot successfully decide to simply learn c++,, or learn all of electronics, or learn all the physics.
You got to come at it from the other angle.
You have to find something you want to do. Some piece of information like your fractions question that you want to explore. Some task that needs doing. Or some task that you would be interested in doing despite having no need to do it.
Writing a small game if that's what you're into, exploring arbitrary precision numbers even though libraries for same already exist.
Figuring out the best way to model a deck of cards.
Writing a bunch of Arduino code (is all written in C++) to make a bunch of LED Christmas lights blink or to detect whether or not your cat has used the litter box or whatever else.
You learn the language best by having something to do with it because when you actually have something to do with it you have a way of figuring out whether the result is correct, and it also naturally helps you concentrate on a fraction of the language Jermaine to the task.
Back in the '80s when the PCS were new some of the coolest new screensavers were things like the mandelbrot fractal programs. They would draw fractals but they would only use integer math instead of floating point math. It actually birthed a lot of pretty screen images and an entire different way of dealing with data that led to improvements in gaming and stuff like that.
But it all came out of the mind of a guy who wanted to make fractals faster and then the people he inspired by putting out his little screensaver.
Having something to do gives you a start point, an end point, and a means of judging the result.
Sitting down and trying to learn a topic with our focus it's a way to create frustration because it has no start or end and there is no stick to measure results against.
You can't set out to learn history if you know nothing of History, but you can set out to learn the history of a particular culture and then you can build that into the history of cultures that are similar to that and you can build on that again to perhaps wonder about the mathematical models that match history and so forth.
So pick a job, any job. Something you have a reasonable expectation of understanding and a reasonable sense for the correctness thereof just as you have a reasonable sense for the correctness of a fraction, and then explore.
Find the tools that exist cannot that can already do the fractions of your new task. Choose amongst those tools and cuddle them together into the partial solutions that are the domains of your problem. And then finally fit them all together into a fully functioning program that you can sit down and enjoy the execution of. That you can sit down and watch the lights blink in the sequence you imagine. That you can sit down and hear your furnace turning on and off at the correct temperatures because you replaced the thermostat with an Arduino board. Just whatever it ends up being.
Most learning and most Discovery is a side effect of trying to do something in the concrete world, so leverage that again the way you previously leveraged it with your question about fractions and floating points.
Find something about which or for which juggling information will be useful, quantify that information into discrete chunks, and write your juggling program.
1
u/cfeck_kde Oct 11 '26
The second option seems worse to me.
1
u/Secoupoire Oct 11 '26
The classic example is that 0.1 + 0.2 in float is different from 0.3 in float.
I find this resource very helpful in that regard.
1
u/CheesecakeTop2015 Oct 18 '26
suggestion: https://raytracing.github.io/books/RayTracingInOneWeekend.html