Someone please help me~ I'm sorry, I'm just a beginner~ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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;

24th Sep 2020, 4:31 PM
Tiara Feryndita Astuti
Tiara Feryndita Astuti - avatar
5 Answers
+ 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; }
24th Sep 2020, 5:04 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 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
24th Sep 2020, 5:12 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
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?)
24th Sep 2020, 4:55 PM
Rellot's screwdriver
Rellot's screwdriver - avatar
0
Coding Kitty Ok, I'm sorry and Thanks a lot ^^
24th Sep 2020, 5:03 PM
Tiara Feryndita Astuti
Tiara Feryndita Astuti - avatar
0
.■. Thank you so much for your help ^^
24th Sep 2020, 5:06 PM
Tiara Feryndita Astuti
Tiara Feryndita Astuti - avatar