[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

C++

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 24
Thread images: 2

File: image.jpg (76KB, 650x366px) Image search: [Google]
image.jpg
76KB, 650x366px
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?
>>
File: 734.png (335KB, 479x464px) Image search: [Google]
734.png
335KB, 479x464px
>>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.
Thread posts: 24
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.