Anonymous
I think MISRA, CERT are more advanced and not always necessary It's better to start what I listed
Also, C++ is advanced. MISRA and CERT define some rules which are really good to obey and guide us to have better and more maintainable code. C++ Best practices on Github? what does even mean? Also, All the conferences talks at CppCon about Having Better C++ Code just was unnecessarily long versions of: - Effective C++ by Scott Mayer - Programming Principles and Practice Using C++ by Bjarne Stroustrup. - Some papers in openstd. So, I think watching them is a waste of time. Sorry, I don't really agree with what you listed.
Anonymous
https://github.com/lefticus/cppbestpractices
Believe me, reading those things is just waste of time: https://github.com/lefticus/cppbestpractices/blob/master/04-Considering_Safety.md#const-as-much-as-possible
Anonymous
Like reading MISRA is a waste of time?
Anonymous
If every C++ developer followed these basic rules, there would be so much less C++ code
If C++ developers don't know those rules when finishing The C++ Programming Language, It's better to don't write C++ code.
Anonymous
It's not necessary to read Stroustroup to be a good C++ developer
Yes, and that's way i suggest to reading: - C++ Core Guide Line. - MISRA. - CERT after reading The C++ Programming Language.
Anonymous
After that, your are welcome to be a Junior C++ Programmer.
Anonymous
You have really high demands for junior developers
Anonymous
You have really high demands for junior developers
😂Why? you don't need to create or discover the existence of the universe theory. All you need to do is just reading some books to be a junior programmer. Then you could start working and gain knowledge. I except every Junior programmer to at least read those books.
сумбула
It's not necessary to read Stroustroup to be a good C++ developer
some people can understand what is really going on behind their codes by reading Stoustroup. However, there are many programmers who are good at coding but when it comes to understanding...ooops
Anonymous
At least you don't require to read Desing and Evolution of C++
Anonymous
Reading is useless without understanding
Do NOT be deceived, it's reader's problem.
miguemunoz
After that, your are welcome to be a Junior C++ Programmer.
In which parallel universe do you live where these books are required for a junior dev role?
Anonymous
You don't accept juniors that didn't read Stroustroup but can code in C++ and for example know some advanced techniques like SFINAE, CRTP?
I don't except and don't ask juniors to write HPC codes or setup a Linux kernel without a hand. A junior must know the fundamentals very well after that could learn those advanced topics you mentioned. Believe me, I see a lot of those programmers how first going for such advanced topics and think they know what they do, but they don't.
Pavel
You don't accept juniors that didn't read Stroustroup but can code in C++ and for example know some advanced techniques like SFINAE, CRTP?
I would think about accepting a junior who flexes with their template-related knowledge :) As juniors usually tend to apply the most complicated solutions they know
Anonymous
I would think about accepting a junior who flexes with their template-related knowledge :) As juniors usually tend to apply the most complicated solutions they know
I was talking about just about knowing, not overusing Abd still, it's a junior, you shouldn't wait the junior to write production ready code right away And a person that knows complicated to learn simple things BUT vice versa is not guaranteed
Pavel
There's one thing about interviewing and teaching, that many interviewers and teachers see experience of other people through their own experience. Some people have written OSes and think that "any good programmer should be able to write an OS", others have read some books and think that every good programmed should have them read. And obviously every one of them can't be right.
Ehsan
they expect you to be superb with solving problems (whether it’s about an os feature or no)
Pavel
Most interviews in good companies have a technical section that seperates the garbage from the good
Of course, but the impression that a person gives to the technical specialist is important, because they decide the scores on the answers (if it's not a test with one correct answer). Therefore it is kind of good to have less prejudice when interviewing people.
Mamas
#include <iostream.h> #include <conio.h> void main() { clscr(); int num1, num2, sum; cout << "\n Enter Two Numbers ::: "; cin >> num1 >> num2; sum = num1 + num2; cout << "\n " << num1 << " + " << num2 << " = " << sum; getch(); }
Vlad
How do you learn C++? what is your resource?
I guess his Uni training materials lol
Vlad
Only they could do this necromancy
Mamas
How do you learn C++? what is your resource?
Read online from www.programiz.com
Mamas
Lol it's SO bad
I wanted correction .. please show me were i made errors..🙏🙏
Anonymous
Read online from www.programiz.com
That is Awful. If you want to learn Programming and The C++ Programming Language, consider reading: https://www.stroustrup.com/programming.html Which is a complete book to starting programming and learning a programming language from the Creator of C++ not some random people on the internet.
Anonymous
Thanks for the advice
You'r welcome, check this to see an edited version of your code.
Pavel
I wanted correction .. please show me were i made errors..🙏🙏
don't use conio.h, it is dos-specific and not official AFAIK use <iostream> header (without .h), the one with .h is old and not supported declare local variables as closer as possible to the first use, int sum = num1 + num2, there's no need to declare them at the top of the function. use std namespace explicitly (std::cout, std::cin)
M
Hello, I am trying to overload + and += operators. I have a class Building that has variables storing floors and entrances. What I am trying to do is to overload + and += in a way that 1) object + int change the number of floors 2) int + object change number of entrances I have already managed to implement the 1) but I struggle with 2). To my understanding 2) should be defined outside of the class as the left argument of the function will NOT be part of the class. How can I do 2)? I tried many things but I failed. For example: Building& operator+(int lhs, const Building & rhs){ unsigned tmp = lhs + get_entrBuilt(rhs); rhs.set_entrBuilt(tmp); return *rhs; }
M
1) is working just fine: Building& Building::operator+(int rhs){ flBuilt += rhs; return *this; } Building& Building::operator+=(int rhs){ flBuilt += rhs; return *this; }
Pavel
Hello, I am trying to overload + and += operators. I have a class Building that has variables storing floors and entrances. What I am trying to do is to overload + and += in a way that 1) object + int change the number of floors 2) int + object change number of entrances I have already managed to implement the 1) but I struggle with 2). To my understanding 2) should be defined outside of the class as the left argument of the function will NOT be part of the class. How can I do 2)? I tried many things but I failed. For example: Building& operator+(int lhs, const Building & rhs){ unsigned tmp = lhs + get_entrBuilt(rhs); rhs.set_entrBuilt(tmp); return *rhs; }
Operator + should be associative as far as I remember, so there's no simple way to make it work. Also it's not a very good idea to overload operators like + and do something that isn't really a sum, not only because it can create bugs when someone accidentally put a wrong sign or used a wrong algorithm or template specialization, that uses this + operator, but it also produces very confusing to the reader code. Better to just use a function and not overcomplicate.
M
I agree with both of you but this is an assignment so I have to try
M
+ is associative but if I am not mistaken an operator can be overloaded to accept different number of arguments, in this situation it is only int and int + object
Pavel
I agree with both of you but this is an assignment so I have to try
Did you try to declare them both outside of the class?
Pavel
I agree with both of you but this is an assignment so I have to try
https://stackoverflow.com/questions/3764604/commutative-operator-overloading-of-2-different-objects
M
yes, it'd be easier if I show you the entire code but I don't think I can paste it here. do you want to see it, i can paste it somewhere
M
as they are outside of the class, I am declaring them without putting Building:: before the operator
Pavel
yes, it'd be easier if I show you the entire code but I don't think I can paste it here. do you want to see it, i can paste it somewhere
You can paste if it short or you can use pastebin/ideone/wandbox and such and paste the link to your code
M
I have this in the header file (outside of the class) Building& operator+(int, const Building &); and here is the definition in the cpp file: Building& operator+(int lhs, const Building & rhs){ unsigned tmp = lhs + get_entrBuilt(rhs); rhs.set_entrBuilt(tmp); return *rhs; }
M
basically I initiate a variable that will sum the int + the current # of built entrances. then I assign the sum to the object and return it
M
maybe the idea is okay but the code breaks somewhere, i get the following error.
M
'get_entrBuilt' was not declared in this scope unsigned tmp = lhs + get_entrBuilt(rhs);
Pavel
'get_entrBuilt' was not declared in this scope unsigned tmp = lhs + get_entrBuilt(rhs);
well, it seems that the problem not in the operator code, but in this function call
Pavel
Check this out: http://ix.io/2UQK
does this also count as rickrolling? :)
M
yes, i just realized it shouldn't be const.. let me try again
M
okay, so there is some progress! I changed the code to: Building& operator+(int lhs, Building & rhs){ unsigned tmp = rhs.get_flBuilt() + lhs; rhs.set_flBuilt(tmp); return *rhs; } the error now is: no match for 'operator*' (operand type is 'Building') basically I am not allow to just return *rhs;
M
any ideas how to proceed from here?
Vlad
It won't work
Vlad
Unless it's a reference to a pointer
M
now it compiled! thank you! vlad doc, I am not really sure what dereferencing a reference is :/ can you explain it?
Vlad
When you use a reference it's automatically dereferenced
Vlad
In contrary to a pointer
Vlad
So when you use it. It's already dereferenced. You don't have to do *var