Created
April 23, 2012 17:11
-
-
Save CameronCarroll/2472348 to your computer and use it in GitHub Desktop.
constructor (cpp)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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