List of all available Websheets
Viewing cpp/cs104/examples/memref by redekopp@usc.edu. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
Property | Value |
---|---|
Description html markup shown to student | Use this program to test various methods of returning an object or pointer/reference to an object from a function. |
Public permissions | |
Remarks Comments, history, license, etc. | Originally by Mark Redekopp (redekopp@usc.edu) and Dave Pritchard (daveagp@gmail.com) |
Engine | |
Template / Reference solution |
using namespace std; class Item { public: Item(int w1, string y1) { w = w1; y = y1; } int w; string y; }; \[ // Function to build an item \show: Item buildItem() { Item x(4, "hi"); return x; } ]\ int main() { \[ // Code to call buildItem and receive return value \show: Item i = buildItem(); cout << i.w << " " << i.y << endl; ]\ return 0; } |
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 | |
Is example? i.e., just a demo | |
Add compiler flag(s) json list of flags e.g. ["-Wno-unused-variable"] | ["-w"] |
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'.