Skip to content

Instantly share code, notes, and snippets.

@davertron
Created August 24, 2011 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davertron/1167992 to your computer and use it in GitHub Desktop.
Save davertron/1167992 to your computer and use it in GitHub Desktop.
#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