Changing the defaults work exactly as you suggested, but it becomes the default for all console apps, which is too big in most cases.
I found an exam question on the internet that asks pretty much exactly what I want done, but it's a little over my ability to answer it.
3) This question is about classes in C++.
Note: All parts of this question should be read thoroughly before any code is written.
a) Declare a class TWindow. It should have 7 member variables: 4 integers to hold left, top, width and height of the window. It should have a pointer to a string that forms the title of the window and 2 more integers to hold the window colour and text colour.
(5 marks)
Implement in C++, four access member functions for the class: ‘SetWinSize’ (to set the size of the window), ‘SetWinTitle’ (to set the title of the window by dynamically allocating the string), ‘SetWinColour’ (to set the colour of the window) and ‘SetTextColour’ (to set the text colour of the window).
(10 marks)
c) Implement in C++ code a class constructor that initialises the window. The constructor should have default values for each parameter (Title, Left, Top, Width and Height of window, WindowColour and TextColour), such that if the constructor is called with no actual parameters it will initialise the object's data members to set the window size to 80x25, the window colour to blue, the window text to white and the title string to NULL.
Implement in C++ the class destructor to release the heap memory used to hold the string.
(7 marks)
Q3 continued on next page……….
d) Assuming that the function ‘Draw( )’ (outlined in Figure 1 below), has been implemented as a member function of the class TWindow, implement a main program section which declares an object of type TWindow called Window1. Window1 should use all the default parameters of the class constructor, but override the title with the string “Window1”. The window should then be drawn by calling the member function ‘Draw( )’.
(3 marks)
(Total: 25 marks)
void TWindow::Draw()
{
textbackground(mWinColour);
textcolor(mTextColour);
window(mLeft,mTop,mLeft+mWidth-1,mTop+mHeight-1);
clrscr();
if (mTitle==NULL) return;
if (strlen(mTitle) > 0)
{
gotoxy((mWidth-strlen(mTitle))/2,1);
cout << mTitle;
}
else mTitle=NULL;
}
It's the part 'c' that I'd especially like answered. If you can make a window that's 80x25, you could just as easily adjust the size.
Archived topic from Iceteks, old topic ID:2254, old post ID:19234