0
Someone please help me~ I'm sorry, I'm just a beginner~
https://code.sololearn.com/cNs3E8195c84/?ref=app Find the error (if any) in each of the following constructor calls Sample first (4): Sample second (); Sample third;
5 Antworten
+ 5
I dont understood Question properly what u expecting through this program actully u missed main function in program see here i tried something according to your question may be you were expecting same Output
#include <iostream>
using namespace std;
class Sample
{
private:
int x;
public:
Sample (int a){
cout<<a<<endl;
}
Sample (void)
{
cout<<"this is counstruct";
}
};
int main()
{
Sample(4);
Sample(6);
Sample();
return 0;
}
+ 5
Is it correct according your expecting you mentioned constructor . I created two constructor which name is same as class name . I created two constructor and called three times first one will print value 4 then again calling so 6 will print after that no paratmer passing so normal text will print
0
I don't have any idea what you're trying to say.
first of all, you didn't mentioned 'int main()' function in your code.
second, you didn't assign the variables(were you trying to make an input?)
0
Coding Kitty Ok, I'm sorry and Thanks a lot ^^
0
.■. Thank you so much for your help ^^