🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.c++.leda
4 messages
4 total messages Started by Bulent Basaran Mon, 25 Sep 1995 15:41
data members of type "a LEDA type" / deriving from a LEDA type
#96
Author: Bulent Basaran
Date: Mon, 25 Sep 1995 15:41
25 lines
1049 bytes
Hi,
I have two questions:

1) Is it possible to have a data member of a user class with a LEDA type?
e.g.,
class C1{
    array<string> A(0, 10);  // an array of strings
}; 
This is not a valid c++ statement, since data members can not be initialized.
Is there a way to correctly implement this?

2) Is it possible to derive from a LEDA type?
e.g., 
class C1: public d_array {
...
}

Thanks in advance,

Bulent
bulent@cmu.edu   basaran@ece.cmu.edu    Dept. of Electrical and Computer Eng.  
+1 412 268 6646 (Office)                Carnegie Mellon University
+1 412 687 4220 (Home)                  
http://www.ece.cmu.edu/afs/ece/usr/basaran/home.html
Re: data members of type "a LEDA type" / deriving from a LEDA type
#97
Author: Marco Nissen
Date: Tue, 26 Sep 1995 07:47
28 lines
1154 bytes
Bulent Basaran (basaran@prelude.ece.cmu.edu) wrote this:
: 1) Is it possible to have a data member of a user class with a LEDA type?
: e.g.,
: class C1{
:     array<string> A(0, 10);  // an array of strings
: }; 
: This is not a valid c++ statement, since data members can not be initialized.
: Is there a way to correctly implement this?

I'd say ...

  class C1 {
    array<string>       A;

    public:

    C1() : A(0,10) {}
    void test() { 
        cout << "low: " << A.low() << " high: " << A.high() << endl; }
  };

  C1 test;

  test.test();

-- 
Marco Nissen [http://www.mpi-sb.mpg.de/~marco]
*this posting was not sponsered by microsoft*
Re: data members of type "a LEDA type" / deriving from a LEDA type
#99
Author: Frank Muzzulini
Date: Tue, 26 Sep 1995 18:54
41 lines
1662 bytes
Bulent Basaran (basaran@prelude.ece.cmu.edu) wrote:

> Hi,
> I have two questions:

> 1) Is it possible to have a data member of a user class with a LEDA type?
> e.g.,
> class C1{
>     array<string> A(0, 10);  // an array of strings
> }; 
> This is not a valid c++ statement, since data members can not be initialized.
> Is there a way to correctly implement this?

When I remember correctly, you have to initalize the member *before* the
normal constructor. Try this:

class C1{
    array<string> A;

    C1() : A(0,10);
	{ }
};


> 2) Is it possible to derive from a LEDA type?
> e.g., 
> class C1: public d_array {
> ...
> }

It is at least possible.
A friend of mine tried to code something like that, but he had some problems
in manipulating the object he derived from. Just try it.

Greetings, Muzz

--
  ___  Frank Muzzulini     ua0y@rz.uni-karlsruhe.de     Muzz@irc
 <*,*>  ... until the colour of a man skin is of no more
 [`-']  significance than the colour of his eyes ...        Bob Marley (War)
 -"-"-
Re: data members of type "a LEDA type" / deriving from a LEDA type
#112
Author: Olivier L'Heureux
Date: Fri, 29 Sep 1995 08:52
40 lines
2212 bytes
In article <449i92$ae6@nz12.rz.uni-karlsruhe.de>
ua0y@rzstud1.rz.uni-karlsruhe.de (Frank Muzzulini) writes:

[...] 
>> Bulent Basaran (basaran@prelude.ece.cmu.edu) wrote:
[...] 
>> > 2) Is it possible to derive from a LEDA type?
>> > e.g., 
>> > class C1: public d_array {
>> > ...
>> > }
>> 
>> It is at least possible.  A friend of mine tried to code something
>> like that, but he had some problems in manipulating the object he
>> derived from. Just try it.

C++ permits it, of course, but be very careful. Many LEDA classes have
been written without thinking about possible derivation.

For instance, the `graph' class is the base class for `GRAPH',
`ugraph' and `planar_map'. But a `ugraph' is a graph with its
`undirected' field set to true, thus the behaviour of the undirected
graph is (partly) implemented in the `graph' class. Thus, if you
derived from `graph', in order not to interfere with `ugraph', you
need to know that `graph' was written with `ugraph' in mind... Tricky.

It is one of the coding practice I regret in LEDA. I suppose it was
hardly avoidable.

>>   ___  Frank Muzzulini     ua0y@rz.uni-karlsruhe.de     Muzz@irc

						Olivier L'Heureux

----------------------------------------------------------------------

Laboratoire de microélectronique de l'Université catholique de Louvain

e-mail:	lheureux@dice.ucl.ac.be	               B-1348 Louvain-la-Neuve         
<URL:http://www.dice.ucl.ac.be/~lheureux>                      Belgium
MIME/PGP accepted
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads