954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

vector subscript inaccessible error

vector<vector <vector<char>>> Sub;
	Sub[0][0].push_back(s[0]);Sub[0][0].push_back('\0');
	Sub[0][1].push_back('\0');

I have the above code and it says "vector subscript insaccessible" for the assignments.What could the reason?
Thanks in advance,
Prasanna

IndianaRonaldo
Light Poster
39 posts since Jan 2011
Reputation Points: 7
Solved Threads: 1
 
vector<vector <vector<char> > > Sub;


Insert spaces in btw and it will be fine. Without spaces compiler will parse it as ">>" rather than "> >".

L0s3r
Newbie Poster
14 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 
vector<vector <vector<char> > > Sub;

Insert spaces in btw and it will be fine. Without spaces compiler will parse it as ">>" rather than "> >".


No.It does't make any difference.Tried.Thanks for the reply though.
Anybody? I have not given a size to the vector.Could it be because of that?
Thanks again.

IndianaRonaldo
Light Poster
39 posts since Jan 2011
Reputation Points: 7
Solved Threads: 1
 

>> I have not given a size to the vector.Could it be because of that?

Well, if your vectors are empty, how could you expect to be able to access elements of them? I think people reading your example assumed it was not real code, just an example of the syntax that was erroneous.

Is your error occurring when you run the program or when you compile it?

You have to populate a vector with elements before you can access any. That's pretty obvious.

mike_2000_17
Posting Virtuoso
Moderator
2,139 posts since Jul 2010
Reputation Points: 1,634
Solved Threads: 457
 

>> I have not given a size to the vector.Could it be because of that?

Well, if your vectors are empty, how could you expect to be able to access elements of them? I think people reading your example assumed it was not real code, just an example of the syntax that was erroneous.

Is your error occurring when you run the program or when you compile it?

You have to populate a vector with elements before you can access any. That's pretty obvious.


It's a run-time error.I'm new with vectors.Anyway figured it out.Thanks anyway.Peace!

IndianaRonaldo
Light Poster
39 posts since Jan 2011
Reputation Points: 7
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: