TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ARRON CUSIMANO
from: KURT KUZBA
date: 1998-02-20 21:58:00
subject: warnings using class

AC> class Vector {
AC>         public:
AC>         double x, y, z;
AC>         Vector();
AC>         Vector(double x1, double y1, double z1);
      void Init(long, long, long);
AC>         Vector (Vector &);
AC>         Vector operator=(Vector &);
AC> }
AC> Vector Vector::operator=(Vector &b)
AC> {
AC>         x = b.x;
AC>         y = b.y;
AC>         z = b.z;
AC>         return *this;
AC> }
      void Vector::Init(long lX, long lY, long lZ)
      { x = lX; y = lY; z = lZ; }
AC> int main(void)
AC> {
AC>     Vector points[NUM_VECT];
AC>     Matrix m;
      points[0].Init( 90, -50, 0);
      points[1].Init(  0, -90, 0);
      points[2] = points[0];
AC>     points[0] = Vector( 90, -50, 0); /* warning here */
AC>     points[1] = Vector(  0, -90, 0); /* & here       */
AC> }
   Your RValue isn't actually a type Vector variable in the
   assignment statements in your example. You want the code to
   create a Vector, then return that vector via overloading of
   the constructor, but you aren't constructing any data object.
   You are just calling the constructor without any data object
   to which it should attach. The examples I inserted show an
   Init() function and proper use of the assignment operation.
> ] Tagline not responding       Accept,  Reject,  Flame........
---
---------------
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)

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™.