Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Initialize an instance with string

$
0
0

@Carl wrote:

I am very new in C++. hope all of you can help me. thanks.
I have tried to initialize an instance of class with string. i follow the ball tutorial to make my own class. but I made the constructor that can take a string as parameter, this string is the path of the file. and will be passed to ofImage::load() to load image.
I called the constructor to create new instance in ofApp::setup(), but it popped up c2280 ofApp::ofApp(void)': attempting to reference a deleted image function.

pic.h

define PIC

include "ofMain.h"

class Pic {
public:
// Constructor
Pic(char* path, float x = ofGetWindowWidth() / 2, float y = ofGetWindowHeight() / 2);

	// Methodl
	void draw();

	// Properties
	float x;
	float y;
	ofImage image;

};

endif

pic.cpp

include "pic.h"

Pic::Pic(char* path, float x, float y) {
image.load(path);
this->x = x - (image.getWidth() / 2 );
this->y = y - (image.getHeight() / 2 );
}

void Pic::draw() {
image.draw(x, y);
}

what's wrong with my class?
thanks.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles