New notation?

I'm confused by lines 39 and 40. They didn't really explain how exactly they work or what they are. Can you guys tell me, please?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
//  TypeConversion - demonstrate the implicit conversion
//                   of one type to another
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

class Complex
{
  public:
    Complex() : dReal(0.0), dImag(0.0)
    { cout << "invoke default constructor" << endl;}
    /*explicit*/ Complex(double _dReal)
      : dReal(_dReal), dImag(0.0)
    { cout << "invoke real constructor " << dReal <<endl;}
    Complex(double _dReal, double _dImag)
      : dReal(_dReal), dImag(_dImag)
    {
        cout << "invoke complex constructor " << dReal
             << ", " << dImag << endl;
    }

    double dReal;
    double dImag;
};

int main(int argcs, char* pArgs[])
{
    Complex c1, c2(1.0), c3(1.0, 1.0);

    // constructor can be used to convert from one type
    // to another
    c1 = Complex(10.0);

    // the following conversions work even if explicit
    // is uncommented
    c1 = (Complex)20.0;
    c1 = static_cast<Complex>(30.0);

    // the following implicit conversions work if the
    // explicit is commented out
    c1 = 40.0;
    c1 = 50;

    system("PAUSE");
    return 0;
}
Those links don't really help me a lot... What are casts? What exactly to they do?
They transforms values from one type to another.
http://www.learncpp.com/cpp-tutorial/44-type-conversion-and-casting/
What does static cast do? Does it convert it to a static?
No, it just converts between data types using defined conversions
http://en.cppreference.com/w/cpp/language/static_cast

There is const_cast which can add or remove const modifier.
http://en.cppreference.com/w/cpp/language/const_cast

Dynamic_cast, which could be used to safely convert pointers and referent inside inheritance hierarchy
http://en.cppreference.com/w/cpp/language/dynamic_cast

Reinterpret cast which doesnt't do anything safe
http://en.cppreference.com/w/cpp/language/reinterpret_cast
Topic archived. No new replies allowed.