home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!glasgow!unix.brighton.ac.uk!je
- From: je@unix.brighton.ac.uk (John English)
- Newsgroups: comp.lang.c++
- Subject: Re: Help with nested class and constructor
- Message-ID: <1992Nov20.154512.22771@unix.brighton.ac.uk>
- Date: 20 Nov 92 15:45:12 GMT
- References: <Bxyxrv.EJ3@news.cso.uiuc.edu>
- Organization: University of Brighton, UK
- Lines: 28
-
- macg9505@uxa.cso.uiuc.edu (Michael Alan Corn) writes:
- :
- : I could use a little help on nested classes:
- : I would like to include one of Borlands Array classes in another class,
- : in the private data section, but since the constructor requires an int to
- : initialize the class, I'm not sure how or where to give it the value:
- :
- : class foo {
- : private:
- : Array myarray(10); ///this doesn't work, the compiler chokes
- ^^^^^^^^^^^
- This is a constructor call to Array, not allowed here.
- That's why the compiler chokes. What you need is:
-
- Array myarray;
-
- in the class declaration, and in the constructor do this:
-
- foo::foo () : myarray (10) { } // Array constructor for myarray
- // gets called at foo construct time.
- --
- -------------------------------------------------------------------------------
- John English | "Yes, understanding today's complex world of
- Dept. of Computing | the future IS a little like having bees live
- University of Brighton | in your head... but, there they are..."
- Janet: je @ unix.brighton.ac.uk | "People who live in windowed environments
- Fax: 0273 642405 | shouldn't cast pointers"
- -------------------------------------------------------------------------------
-