Home arrow C++ Programming

Language Translator

Hacking Zone

Hacking Tools
Attacking

Configure Windows

Windows Configuration

Mix Tutorials

Asterisk
Website Building

Novels

Mix Novels

Human Personality

Body Language
C++ Programming

 

    All Latest Cplusplus related articles. to submit your articles became a membur, it's free or send your article to publisher(at)tutorialsforu(dot)info. 



C++ Exception Handling Print E-mail

C++ Exception Handling

 

This document is intended for those in need of a transparent and nice way to handle program errors. The text will introduce a widely used method for achieving this: exception handling. The described system is available in many programming language such as Java, C++, Modula-3, etc., but here we will focus on C++ exception handling.

There are several good reasons to use exception handling. The most important thing it does is separate error-handling code from your normal code; this greatly clarifies your code. Secondly, it stimulates consequences because errors are being handled in one place and in one manner.

 

Read more...
 
C++ Exceptions Print E-mail

C++ Exceptions

 

              Exceptions provide a way to react to exceptional circumstances (like runtime errors) in our program by transferring control to special functions called handlers.

To catch exceptions we must place a portion of code under exception inspection. This is done by enclosing that portion of code in a try block. When an exceptional circumstance arises within that block, an exception is thrown that transfers the control to the exception handler. If no exception is thrown, the code continues normally and all handlers are ignored.

 

Read more...
 
C++ Pitfalls Print E-mail

C++ Pitfalls

 

              This is an attempt to provide an overview of many of the C++ pitfalls that beginner to moderately experienced C++ programmers often fail to understand. Specifically this addresses mistakes that I've seen from newer KDE contributers over the last couple of years. Please note that this is not an attempt to replace a good C++ reference, but simply to provide an introduction to some often misunderstood concepts and to point out their usefulness.

Read more...
 
Introduction to Templates Print E-mail

Introduction to Templates

                       Inheritance and composition provide a way to reuse object code. The template feature in C++ provides a way to reuse source code.Although C++ templates are a general-purpose programming tool, when they were introduced in the language, they seemed to discourage the use of object-based container-class hierarchies (demonstrated at the end of Chapter 15). For example, the Standard C++ containers and algorithms (explained in two chapters of Volume 2 of this book, downloadable from www.BruceEckel.com) are built exclusively with templates and are relatively easy for the programmer to use.

This chapter not only demonstrates the basics of templates, it is also an introduction to containers, which are fundamental components of object-oriented programming and are almost completely realized through the containers in the Standard C++ Library. You&rsquoll see that this book has been using container examples &ndash the Stash and Stack &ndash throughout, precisely to get you comfortable with containers; in this chapter the concept of the iterator will also be added. Although containers are ideal examples for use with templates, in Volume 2 (which has an advanced templates chapter) you&rsquoll learn that there are many other uses for templates as well.

Read more...
 
Polymorphism & Virtual Functions Print E-mail

Polymorphism & Virtual Functions

 

       

                Polymorphism (implemented in C++ with virtual functions) is the third essential feature of an object-oriented programming language, after data abstraction and inheritance.It provides another dimension of separation of interface from implementation, to decouple what from how. Polymorphism allows improved code organization and readability as well as the creation of extensible programs that can be “grown” not only during the original creation of the project, but also when new features are desired.

Encapsulation creates new data types by combining characteristics and behaviors. Access control separates the interface from the implementation by making the details private. This kind of mechanical organization makes ready sense to someone with a procedural programming background. But virtual functions deal with decoupling in terms of types. In Chapter 14, you saw how inheritance allows the treatment of an object as its own type or its base type. This ability is critical because it allows many types (derived from the same base type) to be treated as if they were one type, and a single piece of code to work on all those different types equally. The virtual function allows one type to express its distinction from another, similar type, as long as they’re both derived from the same base type. This distinction is expressed through differences in behavior of the functions that you can call through the base class.

In this chapter, you’ll learn about virtual functions, starting from the basics with simple examples that strip away everything but the “virtualness” of the program.

 

Read more...
 
Inheritance & Composition Print E-mail

Inheritance & Composition

                 

            One of the most compelling features about C++ is code reuse. But to be revolutionary, you need to be able to do a lot more than copy code and change it.That’s the C approach, and it hasn’t worked very well. As with most everything in C++, the solution revolves around the class. You reuse code by creating new classes, but instead of creating them from scratch, you use existing classes that someone else has built and debugged.

The trick is to use the classes without soiling the existing code. In this chapter you’ll see two ways to accomplish this. The first is quite straightforward: You simply create objects of your existing class inside the new class. This is called composition because the new class is composed of objects of existing classes.

The second approach is subtler. You create a new class as a type of an existing class. You literally take the form of the existing class and add code to it, without modifying the existing class. This magical act is called inheritance, and most of the work is done by the compiler. Inheritance is one of the cornerstones of object-oriented programming and has additional implications that will be explored in Chapter 15.

It turns out that much of the syntax and behavior are similar for both composition and inheritance (which makes sense; they are both ways of making new types from existing types). In this chapter, you’ll learn about these code reuse mechanisms.

 

Read more...
 
new & delete for arrays Print E-mail

new & delete for arrays

 

                In C++, you can create arrays of objects on the stack or on the heap with equal ease, and (of course) the constructor is called for each object in the array. There’s one constraint, however: There must be a default constructor, except for aggregate initialization on the stack (see Chapter 6), because a constructor with no arguments must be called for every object.

When creating arrays of objects on the heap using new, there’s something else you must do. An example of such an array is

MyType* fp = new MyType[100];

 

Read more...
 
Dynamic Object Creation Print E-mail

Dynamic Object Creation

 

            Sometimes you know the exact quantity, type, and lifetime of the objects in your program. But not always.How many planes will an air-traffic system need to handle? How many shapes will a CAD system use? How many nodes will there be in a network?

To solve the general programming problem, it’s essential that you be able to create and destroy objects at runtime. Of course, C has always provided the dynamic memory allocation functions malloc( ) and free( ) (along with variants of malloc( )) that allocate storage from the heap (also called the free store) at runtime.

 

Read more...
 
<< Start < Prev 1 2 3 Next > End >>

Results 1 - 13 of 29
Your Ad Here

RSS socialnet

Add to MyYahoo!
Subscribe in NewsGator Online
Add to Newsburst
Add to Google
Add to My AOL
Add to Pluck
Subscribe in FeedLounge
Add to Windows Live
Add to NetVibes
Subscribe in Rojo
Subscribe in Bloglines
Add to MyMSN
Add to Plusmo for your cellphone
Add to PageFlakes
Add to Technorati
Add to BlinkBits
Assistance planning for retirement requires income and investments
Buy now, guess watches from out partners.
Looking for a easy e-agenda solution?