Not logged in. Log in with GitHub. About Websheets.

List of all available Websheets


Viewing cpp/classes/location_reset by daveagp@gmail.com. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
PropertyValue
Description
html markup
shown to student
 
An example of <tt>struct</tt> with pass-by-value.
Public permissions remove
Engine
Template / Reference solution
 
#include <iostream>
#include <iomanip>
using namespace std;
struct Location { // define a new data type, Location
   int row;       // each Location has a row
   int col;       // each Location has a col
};
\[
void reset_location(Location* loc) {
   loc->row = 0;
   loc->col = 0;
}
\show:
void reset_location(Location loc) {
   loc.row = 0;
   loc.col = 0;
}
]\
void print_location(Location loc);
int main() {
   Location home; // construct a Location
   home.row = 5;
   home.col = 10;
\[
   reset_location(&home);
\show:
   reset_location(home);
]\
   print_location(home);
}
void print_location(Location loc) {
   cout << "row " << loc.row << ", column " << loc.col << endl;
}
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 remove


Optional properties:

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'.