Home » C++ » With the c++ constructor

With the c++ constructor

just learning c++, found in c++ class class use can have different forms of.

the following statement, variable a, B, and C.

of different variable declarations
Complex a (n[0], n[1]), B (n[2], n[3], C; 

and c met Complex C, Complex; can be understood as a structure, declare a variable of type Complex C.

Complex a (n[0], n[1]), by understanding the concept there is a constructor for the c++ class in.

is realized through the following code.
Complex:: Complex (int real_, int imaginary_) {
SetComplexNumber (real_, imaginary_);


joined the constructor, Complex C; it was wrong. And with

Complex:: Complex () {
SetComplexNumber (0,0);



The class- class is divided into

Variable and member function;

A constructor is a member function (with the same name; the constructor class
No constructor program, the compiler will add a default constructor;

A constructor in a program, we should pay attention to all the formal definition of.