Thread View: net.lang.c++
2 messages
2 total messages
Started by sher
Thu, 01 May 1986 01:34
Initializing objects on the heap
Author: sher
Date: Thu, 01 May 1986 01:34
Date: Thu, 01 May 1986 01:34
23 lines
1421 bytes
1421 bytes
Right now I am writing in c++ a program to manipulate a linked list. This means that proceedures and function often want to create objects on the heap since it is a bad idea to return objects on the stack. Also it is a good idea to initialize all objects you create. The only way I know to put an initialized object onto the heap is: foo * fp = new foo; foo f ( init ); *fp = init; If f is a large object with many pieces this is a very wasteful proceedure since this involves copying f into the space of fp after going to the work of creating and allocating f. Is there a better way of doing this? I know it can be done by creating a function that takes fp and initializes it with init but I find this inelegant. Why have constructors if they have to always be bypassed? -- -David Sher sher@rochester seismo!rochester!sher
BSD porting problems
Author: oneill
Date: Thu, 01 May 1986 23:20
Date: Thu, 01 May 1986 23:20
34 lines
1310 bytes
1310 bytes
We are trying to port the c++ compiler to our BSD site and have run up
against a problem in using 'cout <<'. Namely, any program we put it in
bombs out as in the example below. Any ideas?
The program:
% more hello.c
#include <stream.h>
main() {
cout << "123Hello\n";
}
The error:
% hello
Bus error (core dumped)
The debug:
% dbx hello
dbx version 5 of 7/31/84 17:27 (tisstyx).
Type 'help' for help.
warning: core dump ignored
reading symbolic information ...
(dbx) run
bus error in _ostream__lshiftFPC__ at line 471 in file "out..c"
471 ) ) ) == -1)
(dbx) where
_ostream__lshiftFPC__(_auto_this = 0x22ec, _auto_s = "23Hello\n"), line 471 in "out..c"
main(0x1, 0x7fffee9c, 0x7fffeea4), line 4 in "hello.c"
(dbx) q
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