Article View: de.comp.lang.c++
Article #26Re: reference variables
From: Dr. Raimund K. Ege
Date: Thu, 13 Aug 1992 18:56
Date: Thu, 13 Aug 1992 18:56
46 lines
1925 bytes
1925 bytes
In article <2QZ5GEP@mailgzrz.tu-berlin.de>, subiaagb@w350zrz.tu-berlin.de (Andre Pareis) writes:
|> In article <Aug.11.11.30.04.1992.28134@andromeda.rutgers.edu>, tmorgan@andromeda.rutgers.edu (Why? Only I Can Be Me) writes:
|> |> I do something similar to the following:
|> |> class X {
|> |> int &var ;
|> |> public:
|> |> constructor that initializes var...doesn't work.
|> |> destructor
|> |> rest of functions
|> |> .
|> |> .
|> |> .
|> |> } ;
|> |>
|> |> I don't remember the error that I am getting, as I am doing this from memory.
|> |> I hope that what I gave you helps solve my dilemma.
|> |>
|> |> Thanks,
|> |> Talib
|>
|>
|> In Tom Swan's 'Learning C++' I found some lines about this problem.
|> One must convert this reference into a pointer, then all should work.
|> I'll read this part again and then tell the solution, but, since I borrowed
|> the book it could take some time.
|>
Das Problem liegt im Constructor.
Hier die Loesung:
class X {
int &var;
public:
X(int i):var(i) {
...
}
.
.
};
--
Raimund K. Ege School of Computer Science
Florida Int'l University
ege@scs.fiu.edu (305) 348-3381 University Park
ege@servax.bitnet FAX (305) 348-3549 Miami, FL 33199
Technical Details
Message-ID:
<1918@kluge.fiu.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!caen!uflorida!kluge!blitz!egeReferences:
<39478.920808@nasobem.stgt.sub.org> <Aug.11.11.30.04.1992.28134@andromeda.rutgers.edu> <2QZ5GEP@mailgzrz.tu-berlin.de>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!caen!uflorida!kluge!blitz!ege From: ege@blitz.fiu.edu (Dr. Raimund K. Ege) Newsgroups: de.comp.lang.c++ Subject: Re: reference variables Message-ID: <1918@kluge.fiu.edu> Date: 13 Aug 92 18:56:30 GMT References: <39478.920808@nasobem.stgt.sub.org> <Aug.11.11.30.04.1992.28134@andromeda.rutgers.edu> <2QZ5GEP@mailgzrz.tu-berlin.de> Sender: news@kluge.fiu.edu Organization: Florida International Univ. Lines: 46