devxlogo

Tip Bank

Hardcoded Char Arrays

Does your C++ compiler accept the following code? char s[3]=”abc”; // illegal in C++, no place for ” The standard requires that the size of a char array initialized with

Violating an Exception Specification

The implementation ensures that functions having an exception specification should throw only exceptions that are listed in their exception specification. For example: class X{};class Y{};void f() throw X{ throw Y();

Binding a Reference to an Rvalue

In a previous tip, http://www.devx.com/free/tips/tipview.asp?content_id=1585 , I explained the concept of lvalues and rvalues. Binding a reference to an rvalue is allowed as long as the reference is const. The

Extracting a Program’s Name

The name of the executable is stored in the string argv[0]. To access it, declare your main() function as follows: int main(int argc, char ** argv) Even if the application

Helper Functions

The interface of a class consists of its public members. Usually, private members represent implementation details and are not exposed to other classes and users. Private members can be member

ResultSet Interface

Question: If ResultSet is an interface, then why can we call methods like next(), isLast() etc. without defining the method body anywhere in the program? As I understand it, in

JavaBeans vs. Enterprise JavaBeans

Question: What is the difference between a JavaBean and an Enterprise JavaBean? Answer: It is natural to be confused regarding the relationship between JavaBeans and Enterprise JavaBeans (EJBs), because they