Confused | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Confused

#include <iostream> using namespace std; class BankAccount { public: void sayHi() { cout << "Hi" << endl; } }; int main() { BankAccount test; test.sayHi(); } was hoping someone could walk me through what's happening here. I see we're creating a class and making it public but get lost after that.

16th Apr 2018, 12:58 AM
Sir
2 Answers
+ 1
Well I'm not an expert in c++ but since you're in the class lesson. You're making a method "sayHi" and "test" is basically your object of the class BankAccount and "test.sayHi();" is you using the object with the method. This will output "Hi".
16th Apr 2018, 1:06 AM
Paul Yan
Paul Yan - avatar
0
but what's going on with the void part and then the int main and test.sayHi?
16th Apr 2018, 1:04 AM
Sir