Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messagedeclare 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 > >
Post Follow-up to this message"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 > >
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.