J
Jarek Blakarz
Hi
I can see that Int non-default constructor is called at line 3 of main "I =
c;". The "I" object has been constructed in line 1 of main.
I guess that in line 3 the temporary object is beeing created and then assigned
to "I". Am I right ?
thanks for answer.
#include <iostream>
using namespace std;
class Int {
public:
Int(void) { cout << "Default constructor" << endl; }
Int(const char &c) : i(c)
{
cout << "Int(char c), i=" << i << endl;
}
private:
int i;
};
int main(void)
{
Int I;
char c = 'P';
I = c;
return 0;
}
I can see that Int non-default constructor is called at line 3 of main "I =
c;". The "I" object has been constructed in line 1 of main.
I guess that in line 3 the temporary object is beeing created and then assigned
to "I". Am I right ?
thanks for answer.
#include <iostream>
using namespace std;
class Int {
public:
Int(void) { cout << "Default constructor" << endl; }
Int(const char &c) : i(c)
{
cout << "Int(char c), i=" << i << endl;
}
private:
int i;
};
int main(void)
{
Int I;
char c = 'P';
I = c;
return 0;
}