hi,
what i'm trying to do is to make a constructor in a class, which takes in an integer and creates a vector one element long of type int and puts the int into it. this is what i've done:
this compiles and the program runs until the end of this function (after the cout line) after which I get a segmentation fault.
I gather that this is something to do with it trying to access protected memory, though I've got no idea why, or how to fix it. I'm on Linux Mint if that important (will this still happen if compiled on windows?).
thanks in advance for any and all replies.
afrg
ps. I know that this is my second query today, I promise that i do google (or scroogle) before posting, yet what is actually wrong here is being evasive.
That piece of code is fine, so the error must be somewhere else.
A segmentation fault happens if you try to access memory that does not belong to your process which usually is because you try to dereference a pointer that doesn't point to a valid object.