J
jagan
Hi All,
I am trying to learn c++. I studied that construct does not
return anything and can be used
to intialise only objects data memebers. Could someone explain how
following is code is compiling
in that case.
#include <iostream>
using namespace std;
class complx {
double re, im;
public:
// copy constructor
complx(const complx& c) { re = c.re; im = c.im; }
// constructor with default trailing argument
complx( double r, double i = 0.0) { re = r; im = i; }
};
int main() {
complx three = complx(3,4); // Here intialising object by calling
constructor. How three is getting intialised
// If constructor is not
anything.
}
thanks
I am trying to learn c++. I studied that construct does not
return anything and can be used
to intialise only objects data memebers. Could someone explain how
following is code is compiling
in that case.
#include <iostream>
using namespace std;
class complx {
double re, im;
public:
// copy constructor
complx(const complx& c) { re = c.re; im = c.im; }
// constructor with default trailing argument
complx( double r, double i = 0.0) { re = r; im = i; }
};
int main() {
complx three = complx(3,4); // Here intialising object by calling
constructor. How three is getting intialised
// If constructor is not
anything.
}
thanks