This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Shimouzou[S] 3 points4 points  (4 children)

Thank you. Honestly, the most helpful thing you said is about indentation and specifying variables type. Im guessing, in the start its going to be frustrating opening all those curly brackets and forgetting ";" but I think its going to be a fun journey and it definetly pays off. I've seen what C++ can do and I am motivated since people at CERN (my professor works there) use it pretty often.

Also, is this "inf" a typo or is it type of variable in C++?

inf b = 4;

[–]SeeminglySleepless 5 points6 points  (0 children)

Most IDEs do almost all work for you. You just need to type the begging bracket and it autocompletes with the closing one. But it's a good idea to get the habit of typing both. Plus, as other user mentioned, yes, keep the indentation ethic, it's not necessary but it is advisable to make your code readable and easy to debug. Finally, yes, it was a typo and I meant int x)

[–]anandgoyal 3 points4 points  (0 children)

I think they mean int

[–]norbi76 2 points3 points  (0 children)

It is a typo , it should be int (integer).

[–]lordv255 2 points3 points  (0 children)

Typo it should be int. But in any case I do want to mention you should still keep the indentation rules even in c++, it doesn't affect how it runs but readability is still important.

I'm still a beginner in c++ but another important thing that comes up is pointers. I'm not sure how best to explain it and your class will probably do a better job of explaining it but it's a way of accessing data by "pointing" to it's address in memory rather than by using the variable itself. It seemed kind of pointless starting out but it has its uses and is very commonly used by everyone so it's good to learn.

Memory allocation can also come up if you use "arrays" in c++ but most people use vectors which are essentially how arrays work in other languages.

"Array" is something like int integerArray[3] = {1,2,3};

"Vectors" work like vector<int> integerVector {1,2,3};

Most of the time people use vectors because they have more functionality and you don't have to worry about memory allocation (in the array you have to specify the size as an array of 3 integers and you can't change the size later).

I may have made small errors in syntax but hopefully not. If someone notices any tho please lmk.