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

Author Topic: Build error c2248 when passing a pointer in a function  (Read 1301 times)

0 Members and 1 Guest are viewing this topic.

That Martin Guy

  • Newbie
  • *
  • Posts: 27
    • View Profile
Build error c2248 when passing a pointer in a function
« on: April 13, 2015, 04:19:55 pm »
Hello!

So i get these folling errors when i try and run my program:
c:\users\axel\downloads\sfml-2.2\include\sfml\window\window.hpp(521): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
1>          c:\users\axel\downloads\sfml-2.2\include\sfml\system\noncopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
1>          c:\users\axel\downloads\sfml-2.2\include\sfml\system\noncopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1>          This diagnostic occurred in the compiler generated function 'sf::Window::Window(const sf::Window &)'
1>c:\users\axel\downloads\sfml-2.2\include\sfml\graphics\rendertarget.hpp(419): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
1>          c:\users\axel\downloads\sfml-2.2\include\sfml\system\noncopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
1>          c:\users\axel\downloads\sfml-2.2\include\sfml\system\noncopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1>          This diagnostic occurred in the compiler generated function 'sf::RenderTarget::RenderTarget(const sf::RenderTarget &)'
 

When i cut down the code to the one i show below, i found out its because i passed a pointer in a function:
//Note: this is obviously cut down
int main()
{
        sf::RenderWindow mainWindow;
        mainWindow.create(sf::VideoMode(1024, 768), "A window");

        show(mainWindow);
}
void show(sf::RenderWindow window)
{
        ..
        getMenuResponse(window);
        ..
}
void getMenuResponse(sf::RenderWindow window)
{
        ..
}

My question is what i can do to prevent this.


zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Build error c2248 when passing a pointer in a function
« Reply #1 on: April 13, 2015, 04:51:47 pm »
void show(sf::RenderWindow window)
void getMenuResponse(sf::RenderWindow window)

You need to learn basic C++ before trying to use SFML. If you read the error it is quite clear what the problem is.

Quote
when passing a pointer in a function

You are not passing a pointer...

Quote
'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'

You can not copy the window class, so either pass it as a pointer or reference to your function.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

That Martin Guy

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Build error c2248 when passing a pointer in a function
« Reply #2 on: April 13, 2015, 05:00:29 pm »
void show(sf::RenderWindow window)
void getMenuResponse(sf::RenderWindow window)

You need to learn basic C++ before trying to use SFML. If you read the error it is quite clear what the problem is.

Quote
when passing a pointer in a function

You are not passing a pointer...

Quote
'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'

You can not copy the window class, so either pass it as a pointer or reference to your function.
First of all, in the original program down i passed it by pointer, forgot to do it here.
Second of all, i could've sworn that i had tried doing as you told... Obviously i didnt, since its working now.  :P
Thanks for taking your time to answer this  :)