olli
I don't think so
Jussi
Once ypu return the object, it is accessible by whoever called the function
Jussi
No matter if it's a "private"
Jussi
At least in my C++11 programs it works
Jussi
Dunno if something happened in cpp14/17
Jussi
I use this for mutexes, if I need to lock a mutex outside a class
olli
If have a class like this class Foo { Object obj; public: void Get(Object & obj) {} }; You need to pass an obj to get, however you cannot use the member of the class
olli
whereas Object& get() returns the member object
Jussi
No
Jussi
void Get(Object& obj) { obj = obj; }
Jussi
obj=mobj;
olli
yes, but where does the parameter come from?
Jussi
The reference parameter is meant to be OUT
Jussi
It would be a dummy object
Jussi
I dunno
Jussi
I never did it that way
olli
That's what I meant :) I think there is no way to make them exactly the same
Jussi
Well yeah calling them is different
Jussi
But both can return the same thing
olli
void Get(Object& obj) { obj = obj; }
However, this would impose the cost of calling the copy constructor and modified the 'OUT' object would not be reflected inside the class
Jussi
Yep
Jussi
I dislike C++ because of references
Jussi
In C you could just initialize the it as NULL in calling function, and pass a pointer to a pointer
Jussi
well ofc that can be achieved in cpp too, but it is "ugly" cpp :D
Jussi
Are you a Finn too, btw?
olli
And C++11 introduced R-Value References what did not help to make them more comprehensible :D
olli
No, I am from Germany
Jussi
ok, was just wondering, Olli is a Finnish name too
Igor🇺🇦
However, this would impose the cost of calling the copy constructor and modified the 'OUT' object would not be reflected inside the class
I played a little bit with "compiler explorer" regarding returning objects ( clang almost always succeeds in optimizing everything out ) , you can try for yourself with different implementation of "Object" here: https://godbolt.org/g/jp3NLi
Igor🇺🇦
returning Object is almost always better.
olli
returning Object is almost always better.
As always when writing C++, I think it depends on what you want to do :D
Anonymous
Good night
Jussi
As always when writing C++, I think it depends on what you want to do :D
I would love to return a mutex and then find out it returns a ref in some compilers and a copy in others :D
Jussi
Like for some data types its not a big deal to return a copy
Igor🇺🇦
I would love to return a mutex and then find out it returns a ref in some compilers and a copy in others :D
Compiler sould never do anything that changes outcome of the operation. It's a bug if that's happens
Jussi
mm :)
Anonymous
Hello
Anonymous
Can I get a teacher
Jussi
No
Anonymous
Please share : Vodnik/Gosselin JavaScript : The Web Warrior Series 1305078446 | 9781305078444 © 2015 6th Edition
Anonymous
No
Why
Anonymous
Hello. Not sure if anyone here has experience using Vugen. I'm looking for some help using vugen v12. Is there a way you can save the html of a page and validate it during a web_custom_request? The web_reg_find function would let me validate current html elements, but I want to know if a new element appears like a button.
AkhiL
👌
Dheeraj
I have to learn the language..so from where i learn?
𝐧𝐄
You tube programming school
Maaf
You tube programming school
How to copy paste the code from youtube 🤔 ?
𝐧𝐄
👍
Dheeraj
ok
°_°
Can someone help me
Anonymous
with what though?
°_°
I made a maze
°_°
But I have some problem with final part of the code
°_°
It starts but it doesn't work
𝐧𝐄
Hi
𝐧𝐄
You have programmist smile
⠠⠍⠥⠓⠁⠍⠍⠁⠙⠽⠥⠎⠥⠋
🙄🤦‍♂
Anonymous
Hello
Anonymous
Who has books for beginner? Please! Help me!
Anonymous
Hello
𝐧𝐄
Hi
𝐧𝐄
⠠⠍⠥⠓⠁⠍⠍⠁⠙⠽⠥⠎⠥⠋
?
🤝
𝐧𝐄
🤝
Anonymous
Hi guys
Anonymous
Hi guys
Hello
Anonymous
How are u
Anonymous
??
Anonymous
Hello all
Anonymous
How are you today ?
abuyuusuf
Hi
abuyuusuf
What use of this-> ?
Jussi
What use of this-> ?
When struct/class is a pointer
Jussi
Or you got a pointer to a struct/class
Anonymous
I always used to get p. and p-> mixed up
abuyuusuf
I always used to get p. and p-> mixed up
Ya me too confius with object.
abuyuusuf
I means p. .
Anonymous
Guys, i learning cpp can you help me
𝐧𝐄
which is better-Sublime Text-Note pad++