Rishi
https://stackoverflow.com/questions/6255825/what-operators-should-be-declared-as-friends
correctmaninwrongplace
Have someone here worked with copy constructor and overloaded operator = inside the class ?
correctmaninwrongplace
I have the next class : class point{ double x,y; public: point(double a=0. , double b=0.){ x = a; y = b; } point(const point &p){ x=p.x; y=p.y;} point operator =(const point &p) { x = p.x; y = p.y; return *this; } };
correctmaninwrongplace
and i want to make the next asigment :
correctmaninwrongplace
point s(r); point u=s;
correctmaninwrongplace
why does the 2º asigment use the copy constructor instead of asigment operator?
correctmaninwrongplace
Ok i understood
correctmaninwrongplace
as point u=s instantiates the u , the the constructor is called
correctmaninwrongplace
the operator would be used if u would be already instantiated
Naveen
Yes. Correct.
Naveen
point s(r); //copy constructor point u=s; //copy constructor s=u; //assignment operator
Ange
Hi everyone sorry if I'm repeating something has already been asked and answered. I have a basic C programming knowledge, what do you guys think would be a good a book to start learning C++ Thanks a lot
Evgenii
Straustrup
Anonymous
Ange
Straustrup
Thanks a lot, I'll look into that
Russell
It's pretty short and it assumes programming knowledge
Russell
Teaches things in the right order too
Russell
I loved it
Ange
perfect!
Adhi
Guys
Adhi
Whats the role of NASM programming in todays technology
ENOENT
you can Google that
ENOENT
basically, you need it if you want to do stuff C/C++ can't do, or absolutely need something to be incredibly fast
correctmaninwrongplace
goto
correctmaninwrongplace
but not recommended
correctmaninwrongplace
You could get the if in a function and when you need return a value that represents nothing
Anonymous
Continue;
Anonymous
For example:
Anonymous
int some (...) { int true = 1, false = 0; while (1) { if (true) { continue; } if ( false ) return 0; }
Anonymous
If the first 'if' is executed the program will jump to the at first of while
Anonymous
Jumping the second if
Russell
Lambda + return is more idomatic IMO than a while loop
Russell
int true = 1, false = 0 [&] { if (true) { return; } dootherstuff() }();
Russell
C++11...
Anonymous
C++11...
Okay...
Anonymous
I'm C man
Russell
Gotcha
Russell
http://en.cppreference.com/w/cpp/language/lambda
Evgenii
Nested if
VI SH NU_
What are the string length functions in c++
VI SH NU_
.size()
Anything else
Evgenii
Why there would be two functions for one thing
ENOENT
int true = 1, false = 0 [&] { if (true) { return; } dootherstuff() }();
how is this in any way more ideomatic than a simple while loop... :D
ENOENT
Anything else
why would there be anything else?
VI SH NU_
what about strcpy(),strcmp(),strcat(),strcmpi()
VI SH NU_
Ok
ENOENT
if the C++ methods don't work, you made the mistake of using a char array instead of a string
many
Any performance drawback if I use a lot of C library calls in C++ code?
ENOENT
nah
ENOENT
but it's ugly
many
Will the compiler sack those unused library calls?
ENOENT
it should, that depends
Russell
They do literally the same thing
Russell
http://en.cppreference.com/w/cpp/string/basic_string/size
many
They do literally the same thing
Lets step into the two functions and inspect the code underneath
Russell
No they are. I promise.
many
Then it's weird. Why people build two functions for one property?
Russell
Size for comformance with standard containers, length is more idiomatic for strings.
Anonymous
Hey
PVS DurgaPrasad
Hey
Evgenii
Hi
many
Hello
Anonymous
I'm learning c++ but only find tutorials on the basics, is there any tutorials where I can learn more of an intermediate level?
Edurolp
https://t.me/javaebooks/347 here you have some nice resources
Edurolp
btw you can also find a lot of usefull stuff here http://www.cplusplus.com/reference/
Anonymous
Cool, what about tasks to do?
Edurolp
which tasks?
Anonymous
Is there any resources were im given tasks to do, and maybe have the solutions if I can't solve it myself.
Edurolp
mm do you understand spanish?
Edurolp
if so, i can give you some tasks
Edurolp
with solutions in case you get stucked