Hi,
This code is of no use. But I am just curious to know about what
happening here.
#include <iostream>
using namespace std;
class Foo {
private:
int i;
public:
Foo() {
cout << "Foo::Foo() " << endl;
Foo(i);
}
Foo(int i) : i(i) {
cout << "Foo::Foo(i nt)" << endl;
}
~Foo() {
cout << "Foo::~Foo( )" << endl;
}
};
int main(int argc, char *argv[])
{
Foo();
}
I am getting infinite call to "Foo::Foo() ". Program is not even
executing "Foo::Foo(int)" .
Vijay
This code is of no use. But I am just curious to know about what
happening here.
#include <iostream>
using namespace std;
class Foo {
private:
int i;
public:
Foo() {
cout << "Foo::Foo() " << endl;
Foo(i);
}
Foo(int i) : i(i) {
cout << "Foo::Foo(i nt)" << endl;
}
~Foo() {
cout << "Foo::~Foo( )" << endl;
}
};
int main(int argc, char *argv[])
{
Foo();
}
I am getting infinite call to "Foo::Foo() ". Program is not even
executing "Foo::Foo(int)" .
Vijay
Comment