devxlogo

Tip Bank

Initializing Class Members

The following code demonstrates how to initialize class members in the initialiser list for more efficiency: class A{int a;char b;float c;public: A();};A::A():a(0),b(0),c(0){}is more efficient thanA::A(){ a = 0; b =

Changing the Attributes of a File

Say you’re trying to overwrite an existing file, but its attribute is set to “Readonly,” so it generates a “Permission Denied” error. The following code shows how to change the

Handling a Final Empty Parameter

The StringTokenizer and the Missing Token tip tells us how to cater for empty parameters, for example in the comma delimited string following: token1,token2,,token4,,,token7 The tip works well, with the

Bit Shifting in VB

The basic principal of this function is to divide the decimal number by two for bit number of times (if that makes sense). So, if bit 30 was to be

Two-dimensional Arrays

Data that is in rows and columns is usually stored in 2-dimensional arrays. Two-dimensional arrays are declared by specifying the number of rows then the number of columns. Unless specified,

Print “Hello World” in a Mobile Phone Using J2ME

Use a simulator to see the output: import javax.microedition.midlet.*;import javax.microedition.lcdui.*;public class HelloWorld extends MIDlet implements CommandListener { private Command exitCommand; private TextBox tbox; public HelloWorld() { exitCommand = new Command(“Exit”,