C++ Tutorials

81. do...while Loops in C++

By: Abinaya : 2007-09-09

Description: It is possible that the body of a while loop will never execute. The while statement checks its condition before executing any of its statements, and if the condition evaluates false, the entire body of the while loop is skipped. The following C++ program illustrates this.


82. while (1) Loops in C++

By: Reema sen : 2007-09-09

Description: The condition tested in a while loop can be any valid C++ expression. As long as that condition remains true, the while loop will continue. You can create a loop that will never end by using the number 1 for the condition to be tested. Since 1 is always true, the loop will never end, unless a break statement is reached. The following c++ program demonstrates counting to 10 using this construct.


83. continue and break statements in C++

By: Priya : 2007-09-09

Description: At times you'll want to return to the top of a while loop before the entire set of statements in the while loop is executed. The continue statement jumps back to the top of the loop.


84. while Loops in C++

By: Manoj Kumar : 2007-09-09

Description: A while loop causes your program to repeat a sequence of statements as long as the starting condition remains true. The following program shows advantages of a while loop instead of using goto statements.


85. Looping with the keyword goto in C++

By: Lakshmi : 2007-09-09

Description: In C++, a label is just a name followed by a colon (:). The label is placed to the left of a legal C++ statement, and a jump is accomplished by writing goto followed by the label name. The following C++ program illustrates this.


86. Classes with Other Classes as Member Data in C++

By: Kamini : 2007-09-09

Description: It is not uncommon to build up a complex class by declaring simpler classes and including them in the declaration of the more complicated class. For example, you might declare a wheel class, a motor class, a transmission class, and so forth, and then combine them into a car class. This declares a has-a relationship. A car has a motor, it has wheels, and it has a transmission.


87. Where to Put Class Declarations and Method Definitions in C++

By: Ivan Lim : 2007-09-09

Description: Each function that you declare for your class must have a definition. The definition is also called the function implementation. Like other functions, the definition of a class method has a function header and a function body.


88. Interface Versus Implementation in C++

By: Henry : 2007-09-09

Description: Clients are the parts of the program that create and use objects of your class. You can think of the interface to your class--the class declaration--as a contract with these clients. The contract tells what data your class has available and how your class will behave.


89. const Member Functions in C++

By: Emiley J : 2007-09-09

Description: If you declare a class method const, you are promising that the method won't change the value of any of the members of the class. To declare a class method constant, put the keyword const after the parentheses but before the semicolon. The declaration of the constant member function SomeFunction() takes no arguments and returns void. It looks like this:


90. Constructors and Destructors in C++

By: Daniel Malcolm : 2007-09-09

Description: Classes have a special member function called a constructor. The constructor can take parameters as needed, but it cannot have a return value--not even void. The constructor is a class method with the same name as the class itself.