What is the hardest thing in C++?

Pages: 1234
LB wrote:
Variables and pointers by far.
I can see pointers being hard, but what do you mean by 'variables'? That's too broad...
I think in programming (not just C++) OOP is a hard thing to learn. As for C++, I think Catfish would have it with his reply. Pointers, if you find a good reference (like this site's tutorials) are fairly straight forward after using them a few times.
I've actually found object oriented design to be the easiest part of C++, but I think that's just because of how my brain works.
I'm ashamed to admit, but OOP is lost on me. Things where I know I should use classes and such get me so frustrated that I ultimately just avoid structs, classes, etc just to get the code done (if possible).
Maybe scientific computing is the most difficult. You need very advanced mathematical and scientific knowledge, you're working with massively parallel systems, maybe even distributed, you're working with large data and interacting with databases, problems can take supercomputers hours, days, months or even years to solve, the algorithms need to extremely efficient, your math might need to be very precise, the problems you're trying to solve are often new, and you probably wont have much to fall back on.
Last edited on
closed account (1yR4jE8b)

Have you done any OOP in other languages? OOP in C++ is pretty hackish, you could try learning the concepts using a language like Ruby or C#.
@BHX C++ doesn't make a very large difference between an interface and an abstract class like Java does. It might help to learn OOP in Java first, and then come to C++. C++ doesn't make the distinction because it is open to free-form of design, whereas Java sort of forces a consistent design across all Java code. You'll probably find OOP much easier to learn in Java.
Last edited on
As far as hard to program thing go, I would say anything where lives and livelihood of people depends on the quality of your work - that could be an RT application (or the OS itself) where one unexpected submillisecond delay is a catastrophic failure, or even a financial application, where millions are made or lost on those time scales. The kind of software where you (or, realistically, your company) has to pay for every error or delay.

Oh, and that is the hardest thing for C++ in particular because other popular languages aren't capable of dealing with tasks like that (well, C is, but it's harder to use)
Last edited on
LB wrote:
@BHX C++ doesn't make a very large difference between an interface and an abstract class like Java does. It might help to learn OOP in Java first...

That's sort of what I did (except with C#) and it made C++ OOP much easier for most of it.

On another note, how do you do Covariance in C++? It's automatic in C#, but I'm having issues doing that in C++.
Last edited on
I'll try that, been playing with Python too.
According to this, it is most common in C++ and not supported in C#, do you mean a different kind of covariance?
Last edited on

Its very simple in C#. That Wikipedia article is on crack :p however it does have somewhat of an example of what I need... vaguely...
Last edited on
Ah - I guess you are talking about e.g. asigning a std::vector<short> to a std::vector<int>? The compiler treats them as different types so operator= would need to be defined for such a conversion, but you can still do it in a way that looks nice:
Iterators :D

If you're writing the class in question and want to provide operator= definitions for conversions like that, you can do some magic:
You can define the templated operator= so it will error if the type is not assignable from ;)
Last edited on
Yeah, basically, to practice what I've learned in C++, I've decided to re-create the basic objects of the .Net framework (Object, Int32, Int64, Double, etc), kind of doing a small .Net++. Anyways, Having issues making Int32 work with Int64 naturally. I could create more overloading operators, some for each combinations, however this feels like cheating and using too much code.

thank you for those links
Last edited on
You should provide template instantiations of the type traits templates that enable your primitive wrapper classes to work like the real primitives in the context of code that uses those templates to check compatibility. Obviously you wouldn't lie and say they were actually primitive, but you could explain all the other traits.
Last edited on
@L B: I was being sarcastic. By "variables" I literally meant primitive data type variables, ie:
int variable;
Oh, I thought you were talking about the concept of stack-allocated memory, which may actually be slightly confusing to people who have ever used any other language.
other languages use stack-allocated memory as well. You should know heap vs stack no matter what language you use IMO.
Pages: 1234