M
manny
Hi all c++ experts
I have a problem with determining why are certain functions called in
the given code example.
In main, fkcja1(one) [ void fkcja1(A as) ] is called, then in its body
it should call fkcja1(1) but actually B::B(int a) is called (WHY?) and
before returning from fkcja1(one) there is a call to
[ void fkcja1(B be) ] (WHY?)
Why there is no call to void fkcja1(int c) !
I'd be grateful for explaining or hint about language feature
responsible for this behaviour so I could dig for more info.
//code example
#include <iostream>
#include <stdio.h>
using namespace std;
class B;
class B {
public:
B();
B(int a);
};
class A {
public:
A();
fkcja1(B be);
};
void fkcja1(B be)
{
B next(1);
}
void fkcja1(A as)
{
B be(1);
fkcja1(1);
}
void fkcja1(int c)
{
cout << "E\n";
}
B::B()
{
cout << "C" << endl;
A next;
}
B::B(int a)
{
cout << "D\n";
}
A::A()
{
cout << "A\n";
}
int main()
{
A one;
fkcja1(one);
return 0;
}
I have a problem with determining why are certain functions called in
the given code example.
In main, fkcja1(one) [ void fkcja1(A as) ] is called, then in its body
it should call fkcja1(1) but actually B::B(int a) is called (WHY?) and
before returning from fkcja1(one) there is a call to
[ void fkcja1(B be) ] (WHY?)
Why there is no call to void fkcja1(int c) !
I'd be grateful for explaining or hint about language feature
responsible for this behaviour so I could dig for more info.
//code example
#include <iostream>
#include <stdio.h>
using namespace std;
class B;
class B {
public:
B();
B(int a);
};
class A {
public:
A();
fkcja1(B be);
};
void fkcja1(B be)
{
B next(1);
}
void fkcja1(A as)
{
B be(1);
fkcja1(1);
}
void fkcja1(int c)
{
cout << "E\n";
}
B::B()
{
cout << "C" << endl;
A next;
}
B::B(int a)
{
cout << "D\n";
}
A::A()
{
cout << "A\n";
}
int main()
{
A one;
fkcja1(one);
return 0;
}