Prameterized constructor

#include
using namespace std;
class room{
public:
int l,b,h;
room()
{
cout<<“Wow!\n”;
}
room(int l,int b,int h)
{
cout<<l<<" “<<h<<” "<<b<<endl;
}
void input();
void print(){
cout<<“length”<<l;
cout<<“breadth”<<b;
cout<<“height”<<h;
}
};
void room::input()
{
cin>>l>>b>>h;
}
int main()
{
room r1;

room r2(6,7,9);
r2.print();

}
here the output shows

Wow!
6 9 7
length-2breadth7208680height1997893613

Why the last output is this?

Sir, please give me answer as soon as possible

@Diptendu1Nandi in the constructor, you are only taking parameters but you haven’t assigned those values to any variables. If you do
this->l = l;
this->b = b;
this->h = h;
inside the constructor, then the print function will not give garbage values.
Please save your code on ide.codingblocks.com and share the link next time.

Please see at my code

@Diptendu1Nandi here
room(int lr,int br,int hr=90)
{
cout<<“Parameter”;
lr=l;
br=b;
hr=h;
}

this is a constructor, so you have to assign values TO l, b and r, but you’re doing quite the opposite

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.