July 18, 2000

Obtaining the Max Value from an Array

Question: How can I make a function to return and display the maximum number in the following array: int my_array[]={10,3,35,101,65,100}; Answer: First, sort the array. Then display the last element in the sorted array: #nclude #include using namespace std;int main(){ int my_array[]={10,3,35,101,65,100}; // obtain the number of elements int elements

New & Malloc

Question: I understand that most of the time, new and malloc may use the same allocation routines, but does that necessarily mean new calls malloc? I am asking because I want to see all the memory being allocated in my program, but I use both new and malloc. If it’s

Sorting a Vector

Question: I have data in a Vector and need to sort it before displaying iton the screen; how do I do this? Answer: The Java 2 Collections Framework provides a set of convenience methodsfor sorting collections. To sort a Vector, you need only use theCollections.sort(List) method. But you must ensure

Superclass Variables Referencing Subclasses

Question: What is the advantage of declaring a variable as a superclass referenceand then pointing that variable to an instance of a subclass? Theway I see it, I can achieve the same end by declaring objects assubclass references and calling the required methods. Answer: Until you have to write some

RMIC and Inner Classes

Question: Can RMIC make stubs for inner classes? When I tryrmic packagename.OuterClassName$InnerClassName, it doesn’t work. Answer: Yes, RMIC can make stubs for inner classes. However, you must use thefully qualified name of the class to do so. In your example you haveused an “$” instead of an “.” to denote

Debugging in Visual C++

Question: Is there a way to access the call stack debugging information from the code? I would like to print the call stack inside a function, each time it is called. Answer: The stack call information isn’t directly accessible. If you want to access that information, you will have to

Repair, Compact, and Back Up Access MDB

This repair and compact also backs up the Access MDB. Function ValidateMdb(MDB As String) As Boolean This function repairs, compacts, and backs up a database fileand deletes stray LDB (locking files) as it goes. The concept is to copy the file to a BAK version, then repairand compact the BAK

Using Temp Tables in Oracle 8i

Oracle 8i introduces the concept of temp tables. This feature long since enjoyed by SQL Server developers enables data to be visible on a Session orTransaction basis. To create an Oracle 8i temp table use the followingsyntax: Create global temporary table tempTable(id number,value number); This creates a table that is

Dealing with Multi-Recordsets Returned by Compound SQL Statements

Everyone can deal with one recordset easily. However, if a SQL statement is like this: “SELECT a, b FROM Table1 COMPUTER SUM(a), SUM(b),” looping though the recordset will not return the aggregate value. Actually, this SQL will return three recordsets—one by one. Either “EXECUTE of Command object” or “OPEN of