Skip to content

Instantly share code, notes, and snippets.

@CameronCarroll
Created April 23, 2012 17:11
Show Gist options
  • Save CameronCarroll/2472348 to your computer and use it in GitHub Desktop.
Save CameronCarroll/2472348 to your computer and use it in GitHub Desktop.
constructor (cpp)
/* Constructor Example (CPP) */
/* Example code from http://www.horstmann.com/ccj2/ccjapp3.html */
/* Declare a class with a default constructor, and a constructor accepting two double variables. */
class Point
{
public:
Point();
Point(double xval, double yval);
private:
double x;
double y;
};
/* Instantiate a new Point using the second constructor. */
Point p(1, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment