error converting from std::vector to non-scalar type requested

Hi,

The full error message is:

error: conversion from 'std::vector<walls, std::allocator<walls> >' to non-scalar type 'walls' requested

I essentially have a vector (filled with an object called walls) in a class and i wanted a function that could return one of these objects but i get this error.

Any help would be awesome, cheers.
We'd have to see your code, but it looks like you're passing a vector where a wall object is expected.
ok thanks for the reply. That makes sense and i should have realised that was what it was conveying, but i didnt think i was passing a vector. Anyway here's the code:

1
2
3
4
5
6
7
8
9
class weapons{
    private:

    std::vector<walls> projectiles[0];

    public:
    
    walls getwall(int i);
};


1
2
3
walls weapons::getwall(int i){
    return projectiles[i];
}


thanks again
projectiles is being declared as an array of 0 vectors of walls. You declare a vector like this:

std::vector<walls> projectiles;
oh dear silly mistake. Thankyou very much.
:)
Topic archived. No new replies allowed.