First off, DONT POST THE ANSWER in this thread!
I am going to post the offending code and the error generated. If you want to play along, post in here how long approximately it took you to figure ( or post to say you don't know ) the error's cause out and send me a quick PM with what you believe the answer is. Optionally in your post state the amount of C++ experience you have. I will then respond to your post in this thread with a yes or no, depending on if the answer you PMed me was correct. EDIT: Or use the spoiler tag I didn't realize we had... I need to hang out in off topic threads more...
Please do not Google the answer, or if you do, mention that in your post!
I really am curious if it is one of those things people would get immediately or not and how long it would take. Keep in mind, it's not about finding flaws in the code, it's specifically about the compiler error in question.
The code:
/////////////////////////////////// SoundFileCache.h //////////////////////////////////////////
#pragma once
#include "SFML/Audio.hpp"
class SoundFileCache
{
public:
SoundFileCache(void);
~SoundFileCache(void);
const sf::Sound& GetSound(std::string) const;
const sf::Music& GetSong(std::string);
private:
static std::map<std::string, sf::Sound> _sounds;
static std::map<std::string, sf::Music> _music;
};
class SoundNotFoundExeception : public std::runtime_error
{
public:
SoundNotFoundExeception(std::string const& msg):
std::runtime_error(msg)
{}
}
/////////////////////////////////// SoundFileCache.cpp //////////////////////////////////////////
#include "StdAfx.h"
#include "SoundFileCache.h"
SoundFileCache::SoundFileCache(void) {}
SoundFileCache::~SoundFileCache(void) {}
const sf::Sound& SoundFileCache::GetSound(std::string soundName) const
{
std::map<std::string,sf::Sound>::iterator itr = _sounds.find(soundName);
if(itr == _sounds.end())
{
sf::SoundBuffer soundBuffer;
if(!soundBuffer.LoadFromFile(soundName))
{
throw new SoundNotFoundExeception(
soundName + " was not found in call to SoundFileCache::GetSound");
}
sf::Sound sound;
sound.SetBuffer(soundBuffer);
_sounds.insert(std::pair<std::string,sf::Sound>(soundName,soundBuffer));
}
else
{
return itr->second;
}
}
const sf::Music& SoundFileCache::GetSong(std::string soundName)
{
//stub
}
The error:
sfmlsoundprovider.cpp(6): error C2533: 'SFMLSoundProvider::{ctor}' : constructors not allowed a return type
Have fun.