Quick question In reguards to going from python to c++ I found the change really easy am I doing something wrong? I hear a lot of people on here talking about how hard c++ is but I didn't find it hard at all.
Also c++ general thread
It shouldn't be hard
But you probably didn't get to the parts different from Python (memory management, pointers etc.)
>>57336590
Hmm yeah I learned about pointer but not memory's agent anything you'd reccomend me to read?
>>57336619
The C++ Programming Language, 4th ed, by Bjarne himself.
How have you been learning?
>>57336655
By projects and some videos
so I learned C some time back and I want to get into C++. What is the best tutorial out there for those with a decent C background? I don't need to learn from scratch, I essentially want to learn the important differences and the quirks of C++.
Can someone help me wrap my head around what Resource Acquisition Is Initialization (RAII) really is?
>>57336867
personally i went from C to C modular then C++ i think it was a good way to do
#include <iostream>
using namespace std;
class pointer{
public:
pointer(){
int a = 12;
int b = 5;
int* pointer_to_a(&a);
int* pointer_to_b(&b);
cout << pointer_to_a << endl;
cout << pointer_to_b << endl;
int y{*pointer_to_a};
int z{*pointer_to_b};
cout << y << endl;
cout << z << endl;
}
};
int main(){
pointer lolCat;
return 0;
}
>>57336576
compiled languages aren't that great really. Lots of them will still compile even if the code is wrong.
>>57337523
That's why there are debuggers.
>>57337068
some syntax sugar to help with doing all memory allocations when you declare a variable of any type
This is so you dont manually allocate raw memory as often so that you have fewer things to remember to free
Not sure exactly in syntax this means, but i believe that is the general concept
>>57336867
The reference material in www.cplusplus.com should be enough to get you up to speed with basic C++ if you already know C. It also has a standard library reference that is a blessing
>>57337523
Catching most errors > catching nothing until run time
>>57336867
http://courses.cms.caltech.edu/cs11/material/cpp/donnie/
http://courses.cms.caltech.edu/cs11/material/advcpp/
Great way to work through it yourself
>>57336576
did you get the templates and pointers ?
if so congratz, gg, ez
And btw I did the reverse thing, even better.
From C++ to Python (yeppers, higher salary) in a week.
Python is so much more elegant in many ways :)
>>57339505
Yeah thanks k don't really get when you would use templates
>>57339897
everytime you can
>>57339976
Explain when to use them
>>57340646
When you can use this function / class with different type of variable.
Example:
You want to go through a tab, but not necessarily a vector (STD:: list...).
You can use a template here
>>57339897
templates are "variables" that only exist at compile time and hold a type. so for example, you could write a template function that sorts a vector of unknown type <T>, and then instantiate that sort template for integers, floats, etc. that is, <T> = <int>
this is totally distinct from inheritance polymorphism, where you write a function that operates on only ONE type (the base class or "interface"), and then apply that one function exclusively to types that inherit from that base
because templates provide variables at compile time, they are expressive enough to write arbitrary programs, and you can write a compile-time program that generates the code for your run-time program. this is extremely advanced, but it's not irrelevant -- the standard library uses it extensively.
this is the main reason that C++ is hard, along with memory management
>>57336655
Not OP but could you please share pdf? Can't find it on the interwebs, only 3rd ed. Is 3rd good/updated enough?
>>57336576
>>57339897
>found the change really easy
>don't really get when you would use templates
So basically, you don't know C++ at all. Suspicions confirmed.