Max
if the sum of the upper elements is greater than the sum of the lower ones, then sort the whole matrix by decrements and otherwise by ascending order.
Anonymous
@maxkalashnyk02 Don't post long codesnippets here. Use pastebin
Anon
Everytime i am reading spaces woth scanf it appears me T
Anonymous
OK most definitely ,,,
Anonymous
How can i be abest programming some advice please
Egro
Hey
Egro
I need help , I messed up visual studio . I went to view > property manager. Now my projects showing debug folder when I open them. How to return to original view
Egro
Never mind I figure it out 🙃
Emmanuel
Hello guys Please I need someone to help me and explain to me some OOP in cpp. I have spend a lot of hours trying to figure it out but I get confused It’s paid work
artemetra 🇺🇦
hi, i defined this function in my class: inline std::vector<Point> Curve::vector() const { return m_points; } is it possible to return a reference to m_points? i tried doing: inline std::vector<Point>& Curve::vector() const { return &m_points; } but i get 'initial value of reference to non-const must be an lvalue' error
artemetra 🇺🇦
Anonymous
it's a vector, a member variable of class Curve
It is not a good idea to return a reference to member variable. Your function is a const member function. It means that it doesn't change the data members of the class (unless they are mutable). So if you must definitely return a reference, then a const member function has to return a const reference only. It can't return a non const reference because the implicit this pointer is a pointer to a const. If you change your return value to a const reference, then all that you have to do is just remove the & before m_points in the return statement. A reference is not the same as a pointer.
artemetra 🇺🇦
so, the function signature should look something like this? inline const std::vector<Point>& Curve::vector() const {
Anonymous
> It is not a good idea to return a reference to member variable. valid, but how do i make a getter for a vector? const reference? or copying is the only choice thanks for the other points too :D
If you have a vector as a member variable and want to give users read only access to it directly, here are your options: 1) you can return a const reference to it 2) return a copy. 3) you can just return a pair of const iterators to the vector with the caveat that the iterators can be invalidated. (With C++ 20, you can return a range instead) But before you do any of the above, think whether you want the users of your class to be exposed to your class's implementation details. If tomorrow you decide that a vector is not the way to go about and switch to use a coroutine that generates values on the fly instead, then all of your return values will be useless. This would mean any such change would impact your users So you would instead have to think what meaningful things would the client be able to do with the vector if you return it to them. If you know what they are going to do,then you should provide those options as part of your interface.
Deni
so, the function signature should look something like this? inline const std::vector<Point>& Curve::vector() const {
That's right, the only problem on the code above was the & before m_points so instead of: return &m_points; use: return m_points;
Deni
yep, did that
The const after the function is a good practice for getters
artemetra 🇺🇦
yeah, it's there
Egro
Heyy
Egro
When I call a function like this Int main (){ //call Function of int jump here }; Void Int jump(){ }; The code don’t run in visual studio But when I do it like this it run .. Void Int jump(){ }; Int main (){ //call Function of int jump here }; Why?
\Device\NUL
You need function prototype
Egro
Thank you 🙏
Anonymous
Hi
Anonymous
Can anyone help me with a c program
artemetra 🇺🇦
artemetra 🇺🇦
what's the question/problem? what do you need help with?
artemetra 🇺🇦
no
Anonymous
Here
Anonymous
It wont work help
Anonymous
no
Can u help
artemetra 🇺🇦
well you've already a maximum, use the same logic to write the minimum min = rate1 < rate2 ? rate1 : rate2; min = rate3 < min ? rate3 : min;
Anonymous
Ohh
Anonymous
Can u edit the program and send
artemetra 🇺🇦
..you just insert it after the lines where you write the maximum and printf the minimum
Anonymous
Okay ty
Anonymous
Help
artemetra 🇺🇦
what error is it showing
Anonymous
Max output isn't being shown
artemetra 🇺🇦
Max output isn't being shown
when i ran your program, i had to press enter twice so that max was shown, not sure why that happens, i mostly use C++
Anonymous
Oh
Anonymous
Where did u run it
Anonymous
This isn't working either
artemetra 🇺🇦
D:\>gcc bruh.c D:\>a.exe Enter quantity of 1st 2nd and 3rd item : 8 6 3 Enter price of 1st 2nd and 3rd item: 2.0 3 77 . 231 is maximum revenue 16 is minimum revenue i had to put enter another character and press enter so that the output would be shown
Anonymous
Ohh
Anonymous
Still not running
\Device\NUL
Solved ?
Anonymous
Solved ?
Its showing err
Anonymous
Ig it's the compiler err
\Device\NUL
Anonymous
Permission denied
Anonymous
Wait I'll copypaste
Anonymous
Message ?
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot open output file tempCodeRunnerFile.exe: Permission denied collect2.exe: error: ld returned 1 exit status [Done] exited with code=1 in 2.05 seconds
\Device\NUL
That's not compile error
\Device\NUL
Then
The problem is permission
Anonymous
Ohh
Anonymous
How can I fix it
\Device\NUL
How can I fix it
You compile it with standard user right ?
Anonymous
Yeah ig
Peace
why the answer is some garbage value when I am taking value at run-time ? #include <bits/stdc++.h> using namespace std; int main(){ int n1; cin>>n1; int limit=sqrt(n1); // returning some garbage value cout<<limit; return 0; }
\Device\NUL
Yeah ig
Do you compile in right directory ?
Anonymous
Help
Andrii
cout << setprecision(12) << 0.123f; output: 0.123000003397 Where in the world setprecision gets last 4 digits from if float is not so precise?
Suka
cout << setprecision(12) << 0.123f; output: 0.123000003397 Where in the world setprecision gets last 4 digits from if float is not so precise?
because thats how float or double are stored in pc try read ieee 754 for more detail. some nice link. https://www.exploringbinary.com/floating-point-converter/
Suka
I've remembered, thx.
you're welcome
Azhar
Anyone help me out plz, im in learning period of C..
Azhar
I have a question
Azhar
I can’t post here.. Media not allowed
Anonymous
Is somebody familiar with theoretical computer science like pumping lemma or deterministic finite automata