SFML community forums
Help => Audio => Topic started by: Cryonic on July 24, 2015, 02:13:26 am
-
I am getting the following error:
error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
After I put my declaration in my class header file:
vector<sf::Music> music;
-
sf::Music is non copyable.
std::vector makes copies of its elements.
You can make a vector of pointers (or smart pointers) to sf::Music.
http://www.gamedev.net/topic/631713-sfml-sfmusic-cannot-be-copied/#entry4982914
-
How exactly am I supposed to word it out? I am getting an error on the "openFromFile" line.
I am hovering above it, and it says "Error: expression must have class type"
// Header file
class MyClass
{
vector<sf::Music*> music;
MyClass();
}
// Source file
MyClass::MyClass()
{
for (int i = 0; i < MAX; i++)
{ music.push_back(new sf::Music()); }
music[0].openFromFile("soundFile.ogg");
}
-
It looks like you lack some basic C++ knowledge maybe? Reading a good book could help. Since your vector contains pointer, you need to use -> instead of . to access the members and functions of the sf::Music pointer.