I am trying to initialize the second constructor by forcing the constructor to use just 1 parameter instead of 2. I expected 3,8 to be passed from Foo goo.
works fine:
Foo foo;
foo.makeNestedloop(7,5); //works fine
error:
Foo goo;
goo.makeNestedloop(3);// no defult constructor applied
#include<iostream>
class Foo
{
private:
int outer=6;
int inner=8;
public:
makeNestedloop(int inner, int outer)
{
for(int i(0); i<=inner;++i ) //outer
{
std::cout<<i<<" ";
for (int j(0); j<=outer;++j)//inner
{
std::cout<<j<<" ";
}
std::cout<<std::endl;
}
}
};
int main()
{
Foo foo;
foo.makeNestedloop(7,5); //works fine
Foo goo;
goo.makeNestedloop(3);//errors
}
[output]
In function 'int main()':
..\src\main.cpp:32:21: error: no matching function for call to 'Foo::makeNestedloop(int)'
goo.makeNestedloop(3);//
[output]