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

Author Topic: .  (Read 3719 times)

0 Members and 1 Guest are viewing this topic.

Helios101

  • Newbie
  • *
  • Posts: 15
    • View Profile
.
« on: January 30, 2014, 01:21:03 am »
.
« Last Edit: May 03, 2018, 05:26:01 am by Helios101 »

eigenbom

  • Full Member
  • ***
  • Posts: 228
    • View Profile
Re: What is sf::NonCopyable::NonCopyable'?
« Reply #1 on: January 30, 2014, 01:22:25 am »
You need to pass by reference (or pointer).

Code: [Select]
void Gameplay(sf::RenderWindow& Display)
{
   ...
}

In general, read up about pass by value and pass by reference, as they are important C++ concepts. :D

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: What is sf::NonCopyable::NonCopyable'?
« Reply #2 on: January 30, 2014, 02:23:20 am »
In general, read up about pass by value and pass by reference, as they are important C++ concepts. :D

This is what you need to do, instead of coming here asking very, very basic C++ questions  ;)


sf::RenderWindow& Window(sf::VideoMode(screenDimension.x, screenDimension.y), "Games States");

You can't initialize references.....  :P


int main()
{
     sf::RenderWindow Window(sf::VideoMode(screenDimension.x, screenDimension.y), "Games States");
     DoSomething(Window);
}
void DoSomething(sf::RenderWindow& MyWindowReference)
{
}
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Veltas

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: What is sf::NonCopyable::NonCopyable'?
« Reply #3 on: January 30, 2014, 02:33:32 am »
In general, read up about pass by value and pass by reference, as they are important C++ concepts. :D
This is what you need to do, instead of coming here asking very, very basic C++ questions  ;)

No, disregard zsbzsb, he's old and grumpy. You should come here and ask plenty of questions that could be answered with a basic grasp of C++, because it's not insane to try and make C++ more interesting while trying to learn it.

EDIT: I'd like to point out that this above line was not as abrasive as it sounds, me and zsbzsb were mucking around a bit on #sfml.

Good luck learning C++ and I hope to see something productive of your SFML usage some day.
« Last Edit: January 30, 2014, 11:49:02 pm by Veltas »
< veltas> MJBrune: Debian GNU/Linux
* MJBrune mounts veltas

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6275
  • Thor Developer
    • View Profile
    • Bromeon
Re: What is sf::NonCopyable::NonCopyable'?
« Reply #4 on: January 30, 2014, 06:54:33 pm »
No, disregard zsbzsb, he's old and grumpy.
Don't start to offend other people just because you don't like their opinion. Especially when their tone is friendly and even helpful (note how zsbzsb also showed the correct code).

zsbzsb's point is a good one: You can't learn SFML when you lack the basic understanding of the C++ language. I know there are plenty of people who don't believe this, they'll always make their lives harder than necessary. And I really mean that, because I've made exactly the same experience when I began... In hindsight I could have saved so much time and troubles ;)

See also this post for a more detailed explanation.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: What is sf::NonCopyable::NonCopyable'?
« Reply #5 on: January 30, 2014, 06:59:16 pm »
Don't start to offend other people just because you don't like their opinion. Especially when their tone is friendly and even helpful (note how zsbzsb also showed the correct code).

No worries, we were joking about this a little bit on IRC  :D

And speaking of that, Nexus you should come join us (irc.boxbox.org #sfml) and since you are the "leader" of SFML we can discuss things  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: What is sf::NonCopyable::NonCopyable'?
« Reply #6 on: January 30, 2014, 09:32:41 pm »
Although other people have already given good answers on what to do to fix your code it seems to me that no one actually answered the original question "What is sf::NonCopyable::NonCopyable". So let me just briefly do that.

sf::NonCopyable is a class that, if you inherit from it, will make it impossible to create a copy of an instance of your derived class. It does this by making the copy-constructor and copy-assignment operator private.
This is useful when copying an instance of a class would lead to incorrect or undesirable behaviour.

The documentation for the class is available here: http://www.sfml-dev.org/documentation/2.1/classsf_1_1NonCopyable.php.

Veltas

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: What is sf::NonCopyable::NonCopyable'?
« Reply #7 on: January 31, 2014, 12:01:07 am »
Don't start to offend other people just because you don't like their opinion.

Yes, sorry Nexus: this was a silly joke with zsbzsb and I've edited my comment to make that clear. I don't want to drag down the reputation of the SFML forum at all.

zsbzsb's point is a good one: You can't learn SFML when you lack the basic understanding of the C++ language. I know there are plenty of people who don't believe this, they'll always make their lives harder than necessary. And I really mean that, because I've made exactly the same experience when I began... In hindsight I could have saved so much time and troubles ;)

I think it really depends on the person: I found C++ easier when trying to learn from the ground up with a good book. But I know people who dove straight into trying to use libraries etc. and still had a good time of it. It doesn't sound implausible to me.

Also, at what stage have you learnt basic C++? He may well have learnt about basic structure, functions and classes without having properly taken in references by coincidence. Should one completely abstain from trying out things until they're fully up to date with ISO/IEC 14882:2011?
< veltas> MJBrune: Debian GNU/Linux
* MJBrune mounts veltas

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: What is sf::NonCopyable::NonCopyable'?
« Reply #8 on: January 31, 2014, 07:01:47 pm »
zsbzsb's point is a good one: You can't learn SFML when you lack the basic understanding of the C++ language. I know there are plenty of people who don't believe this, they'll always make their lives harder than necessary. And I really mean that, because I've made exactly the same experience when I began... In hindsight I could have saved so much time and troubles ;)

Also, at what stage have you learnt basic C++? He may well have learnt about basic structure, functions and classes without having properly taken in references by coincidence. Should one completely abstain from trying out things until they're fully up to date with ISO/IEC 14882:2011?
Yes haha! But in all seriousness, no. Sure experimenting with librairies is a good thing, but they should know correctly the fundamentals of C++. Reference is a fundamental. I'm not saying they should not all idioms and produce perfect idiomatic code, but they should know about reference, operator overloading(at least the rules of three(which would have explain a little bit the problem with the non-copyable class)), and other things like that.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord