Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Subject: Use of new and delete in C++
Hi,

I am working on a way to create a "window" within a dos console.  I'm
using Microsoft Visual C++.  My main problem is that I am using new to
create a new CHAR_INFO array within the constructor, and I want to destroy
it within the destructor using delete.  However, the array is not known
outside of the constructor.  This is a class within a class.  Until the
object is created, it has no way to know the size of the array; the size is
passed as a parameter to the constructor.  Is there a way to make the
destructor aware of the array, or to make it public to the class from within
the constructor?  I am using it to store the original information of the
screen that will be overwritten, so that when the window is finished, it can
rewrite the original information (including the background and foreground
color) before the "window" is completely destroyed.

On a side note, has anybody else written advanced console applications?  How
did you handle "windows"?  If I can get this to work properly, I plan to,
eventually, use it to create menus and so on within the console.

Thanks in Advance,
Eric



Report this thread to moderator Post Follow-up to this message
Old Post
Eric A. Johnson
03-26-05 01:57 AM


Re: Subject: Use of new and delete in C++
declare a pointer at the level of scope you need, and create the storage it
points to in the constructor with 'new'.  use "delete [] pointer;" in the
destructor.

"Eric A. Johnson" <nothere@dontlookforme.com> wrote in message
news:7q11e.15490$C47.11253@newssvr14.news.prodigy.com...
> Hi,
>
>     I am working on a way to create a "window" within a dos console.  I'm
> using Microsoft Visual C++.  My main problem is that I am using new to
> create a new CHAR_INFO array within the constructor, and I want to destroy
> it within the destructor using delete.  However, the array is not known
> outside of the constructor.  This is a class within a class.  Until the
> object is created, it has no way to know the size of the array; the size
is
> passed as a parameter to the constructor.  Is there a way to make the
> destructor aware of the array, or to make it public to the class from
within
> the constructor?  I am using it to store the original information of the
> screen that will be overwritten, so that when the window is finished, it
can
> rewrite the original information (including the background and foreground
> color) before the "window" is completely destroyed.
>
> On a side note, has anybody else written advanced console applications?
How
> did you handle "windows"?  If I can get this to work properly, I plan to,
> eventually, use it to create menus and so on within the console.
>
> Thanks in Advance,
> Eric
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
BobF
03-26-05 08:58 AM


Re: Subject: Use of new and delete in C++
"BobF" <rNfOrSePeAzMe@charter.net> wrote in message
news:%23EfyTLaMFHA.1392@TK2MSFTNGP10.phx.gbl...
> declare a pointer at the level of scope you need, and create the storage
> it
> points to in the constructor with 'new'.  use "delete [] pointer;" in the
> destructor.
Did it... thanks! :-)
>
> "Eric A. Johnson" <nothere@dontlookforme.com> wrote in message
> news:7q11e.15490$C47.11253@newssvr14.news.prodigy.com... 
> is 
> within 
> can 
> How 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Eric A. Johnson
03-26-05 08:59 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Studio archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:55 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.