【发布时间】:2017-11-21 02:29:18
【问题描述】:
我有以下类文件
#pragma once
#include <memory>
#include <iostream>
#include <SFML/Graphics.hpp>
class gif
{
public:
gif(const std::vector<std::shared_ptr<sf::Texture>>& textures);
sf::Texture getAt(int);
private:
std::vector<std::shared_ptr<sf::Texture>> textures;
};
gif::gif(const std::vector<std::shared_ptr<sf::Texture>>& c)
{
textures = c;
}
sf::Texture& gif::getAt(int index)
{
return textures.at(index);
}
可变纹理似乎不像传统矢量那样工作,并且没有at(int) 函数来指向我的矢量中的元素。我如何能够使用integer 指向textures 中的某个sf::Texture。
我尝试在谷歌搜索,但似乎无法找到任何可以帮助我的东西。我只是没有正确理解std::shared_ptr吗?如果我不是,那我将如何使用它。
【问题讨论】: