List of all available Websheets
Viewing cpp/classes/the_count by daveagp@gmail.com. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
Property | Value |
---|---|
Description html markup shown to student | Calling a member function from inside of another member function. |
Public permissions | |
Engine | |
Template / Reference solution |
using namespace std; // counter.h class Counter { public: Counter(); void add_one(); void add_one_and_print(); private: int value; }; // counter.cpp Counter::Counter() { value = 0; } void Counter::add_one() { value++; } void Counter::add_one_and_print() { // how do we call a method on the current object? \[add_one();\show:the_count.add_one();]\ cout << value << endl; } // test code int main() { Counter the_count; the_count.add_one_and_print(); } |
C++ test suite json list of stdin/args tests e.g. [{"stdin":"hi", "args":["4", "5"]}, {"stdin":"noargs"}] to just run once with no input use [{}] | [ {} ] |
Solution visibility |
Note: problems are open-source by default (see 'Public permissions'). Assumed license for open problems is Creative Commons 4.0 Attribution-ShareAlike unless specified in 'Remarks'.