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

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.
PropertyValue
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 remove
Remarks
Comments, history, license, etc.
 
Originally by Mark Redekopp (redekopp@usc.edu) and Dave Pritchard (daveagp@gmail.com)
remove
Engine
Template / Reference solution
 
#include <iostream>
#include <string>
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 remove
Is example?
i.e., just a demo
remove
Add compiler flag(s)
json list of flags
e.g. ["-Wno-unused-variable"]
 
["-w"]
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'.