a little bit offtopic: c++ question in kdevelop-tutorial

Depoorter, Stephan SDP at bvdep.com
Fri Feb 25 08:29:35 GMT 2000


It's the initializer-list.
The goal is to initialize class-members, before the constructor is called.
(if your class contains const objects you have to initialize them there,
because
in the constructor you cannot assign a value to them anymore, just because
they are const.
Hope this helps.

-----Original Message-----
From: AndiX33 at aol.com [mailto:AndiX33 at aol.com]
Sent: Thursday, February 24, 2000 10:09 PM
To: kdevelop at barney.cs.uni-potsdam.de
Subject: a little bit offtopic: c++ question in kdevelop-tutorial


hello, 

while reading the tutorials shipped with kdevekop, i´ve read an example i 
don´t understand. and i hope that within this list there are people skilled 
an experienced in programming.

the example:

 .....
1       class Math:
2       {
3       public:
4       //Constructor contains definition of PI
5       Math ():  PI (3,142) {}
6       ~Math () {}
7       float  diameter (float radius)
8       {
9       return ( radius * PI )
10      }
11      private:
12      // declare PI. we cann´t assign a value
13      const float PI
14      }

what does the ":" in line 4?? is it a kind of operator or what does it
it seems strange to me and i didn´t find a solution in books.
why you don´t write:

Math::Math ()
{
   pi=3,142;
}
 
greetings 
andreas schmitzer
    





More information about the KDevelop mailing list