Passing a vector to a function

as the title states i'm trying to send a vector to a function however i am getting these errors


error: invalid initialization of non-const reference of type 'std::vector<sf::Texture>&' from an rvalue of type 'std::vector<sf::Texture> (*)(sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::Texture, sf::T|

error: in passing argument 1 of 'int set_explosion_textures(std::vector<sf::Texture>&)'|


my relevant code is

1
2
3
4
5
6
7
8
9
10
//vector containing fighter explosion frames
    std::vector<sf::Texture> f_explosion_textures(sf::Texture f_explosion_1, sf::Texture f_explosion_2, sf::Texture f_explosion_3,
    sf::Texture f_explosion_4, sf::Texture f_explosion_5, sf::Texture f_explosion_6, sf::Texture f_explosion_7,
    sf::Texture f_explosion_8, sf::Texture f_explosion_9, sf::Texture f_explosion_10, sf::Texture f_explosion_11,
    sf::Texture f_explosion_12, sf::Texture f_explosion_13, sf::Texture f_explosion_14, sf::Texture f_explosion_15,
    sf::Texture f_explosion_16, sf::Texture f_explosion_17, sf::Texture f_explosion_18, sf::Texture f_explosion_19,
    sf::Texture f_explosion_20, sf::Texture f_explosion_21, sf::Texture f_explosion_22, sf::Texture f_explosion_23,
    sf::Texture f_explosion_24, sf::Texture f_explosion_25, sf::Texture f_explosion_26, sf::Texture f_explosion_27,
    sf::Texture f_explosion_28, sf::Texture f_explosion_29, sf::Texture f_explosion_30, sf::Texture f_explosion_31,
    sf::Texture f_explosion_32, sf::Texture f_explosion_33, sf::Texture f_explosion_34, sf::Texture f_explosion_35);



set_explosion_textures(f_explosion_textures);

1
2
3
4
int set_explosion_textures(std::vector<sf::Texture> &fighter_explosion_texture)
{
    //set textures
}


i don't want ways to improve my code unless it will fix my problem
I haven't used this stuff, but the last parameter appears to be a sf::T, that you don't appear to have.

However the compiler is complaining about initialisation. Are you sure you've posted all the relevant code? We don't know the types of all those symbols you've used.
it says that all the f_explosions are of type sf::Texture
std::vector<sf::Texture> f_explosion_textures(sf::Texture f_explosion_1, /**/ );
I think that's a function.

set_explosion_textures(f_explosion_textures);
If you pretend to call the function then it should be set_explosion_textures(f_explosion_textures());

However, that function would return a temporary, that cannot be bind to a non-const reference
Either `set_explosion_textures()' should not ask for a non-const reference, or you should not try to pass a temporary to it.
However the compiler is complaining about initialisation. Are you sure you've posted all the relevant code? We don't know the types of all those symbols you've used.


what symbols?

the initialization is the vector.
it is complaining about it being initialized here:

set_explosion_textures(f_explosion_textures);
I think ne555's right. Please re-read his post.
its my code
Topic archived. No new replies allowed.