Created
August 24, 2011 12:52
-
-
Save davertron/1167992 to your computer and use it in GitHub Desktop.
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
#include <iostream> | |
using namespace std; | |
class Whatever { | |
private: | |
float *color; | |
public: | |
Whatever(); | |
Whatever(float*); | |
~Whatever(); | |
float* getColor(); | |
void printColor(); | |
}; | |
Whatever::Whatever() : color(new float[3]) { | |
color[0] = 0.0; | |
color[1] = 0.0; | |
color[2] = 0.0; | |
} | |
Whatever::Whatever(float* _c){ | |
color[0] = _c[0]; | |
color[1] = _c[1]; | |
color[2] = _c[2]; | |
} | |
Whatever::~Whatever(){ | |
delete [] color; | |
} | |
float* Whatever::getColor(){ | |
return color; | |
} | |
void Whatever::printColor(){ | |
cout << "Color is: (" << color[0] << ", " << color[1] << ", " << color[2] << ")" << endl; | |
} | |
int main(int argc, char** argv){ | |
{ | |
Whatever w; | |
w.printColor(); | |
} | |
//{ | |
float* color = new float[3]; | |
color[0] = 1.0; | |
color[1] = 1.0; | |
color[2] = 1.0; | |
Whatever w(color); | |
w.printColor(); | |
delete[] color; | |
//} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment