TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CAMERON CLARK
from: ALBERTO MONTEIRO
date: 1997-12-16 19:31:00
subject: What`s wrong with this?

AM>   Vector(double xx = 0, double yy = 0);    // constructor
CC>    Are two default values legal?
I guess it is
AM> Vector Vector::operator+(const Vector & V2) const
AM> {
AM>   Vector add;
AM>
AM>   add.x = x + V2.x;
AM>   add.y = y + V2.y;
AM>   return add;
AM> }
It wasn't working since I had comminted a mistake before, using new with
a wild integer. I guess the temporary storage area was full of garbage,
so temporary objects were crazy.
CC>String operator+(String& left, String& right) {
CC>  String str;
CC>  strcat(str.s, left.s); <- I guess here it should be strcpy
CC>  strcat(str.s, right.s);
CC>  str.getLength();
CC>  return str;
CC>}
CC>    I used the same type of temporary in the same type situation
CC>    with no problems.
CC>    return str;
CC>    Returns the value of the 'str' object before it is deallocated.
I had used the operator+ as above, but latter I found it would be more
elegant to make it a member function
Alberto Monteiro
---
 þ SLMR 2.1a þ Build my fear of what's out there (Metallica)
--- FMail/386 1.02
---------------
* Origin: CentroIn! +55-21-205-0281, 41 lines, 24h, RJ/Brazil (4:802/21)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.