creating class problem | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

creating class problem

hey guys, I was trying to solve this problem and I apparently I did it but when I run it on code playground Solo learn it fails. I am not sure why, can anyone tell me what was goin on with this code please; #include <iostream> using namespace std; class Number { private: int num; int num2; public: Number(int n, int i ) { num = n; num2 = i ; } //complete the method int square()const { return num * num2; }; }; int main() { int x; int i; cin >> x; cin >> i ; const Number myNum(x,i); cout << myNum.square(); }

26th Feb 2021, 3:33 AM
JRAMAHES
JRAMAHES - avatar
3 Respostas
+ 1
https://code.sololearn.com/c0eF6UITG8mX/?ref=app your code works fine for me... did you provide input as required? meaning all at once, line separated: 14 3 should output: 42 ... or what are you expecting as result?
26th Feb 2021, 3:45 AM
visph
visph - avatar
0
yes, I did test it. and it works fine. but like it said, when I enter the code to the playground sololearn it fails. so the first test case fail.
26th Feb 2021, 5:47 AM
JRAMAHES
JRAMAHES - avatar
0
what are exactly the requirements? how could a function square be designed to return multiply of 2 numbers?
26th Feb 2021, 5:49 AM
visph
visph - avatar