Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: error C2248  (Read 3002 times)

0 Members and 1 Guest are viewing this topic.

Cryonic

  • Newbie
  • *
  • Posts: 16
    • View Profile
error C2248
« 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;


G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: error C2248
« Reply #1 on: July 24, 2015, 02:41:09 am »
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

Cryonic

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: error C2248
« Reply #2 on: July 26, 2015, 10:36:07 pm »
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");
}
« Last Edit: July 26, 2015, 10:50:13 pm by SFML_Guy »

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: error C2248
« Reply #3 on: July 27, 2015, 02:10:59 am »
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.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord