Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

Initialize an instance with string

$
0
0

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
}

Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>