Initialize an instance with string

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.

I’m pretty sure that the issue is that your Pic class does not have a constructor that takes no arguments. This is also known as a “default constructor” in C++. See this page for a reference (the website tends to be very dense, but also tends to be very accurate): http://en.cppreference.com/w/cpp/language/default_constructor

Although you didn’t give the code, I can hypothesize that you have an instance of Pic as a member of the ofApp class. When the program tries to construct an ofApp, it also tries to construct all of the members of that class, including the instance of the Pic class. However, you have only defined a constructor for the Pic class that takes arguments, but when the program tries to construct it in the ofApp constructor, arguments for the Pic constructor are not available, so it tries to call a version of the constructor that takes no arguments. It is unable to find one and gives an error.

I’m not sure of the exact logic that leads it to claim that the constructor has been deleted, versus saying that it was never defined, which seems more logical from the user’s perspective in this case.

The solution is to make a constructor for the Pic class that takes no arguments. It doesn’t have to do anything at all, it just has to exist. It could be

Pic::Pic(void) {
    //Do nothing
}