Can someone help me find the error that keeps this prg from running
thanx

#include <iostream>

#include <vector>

using namespace std;

int main()
{
	vector<int>v(1,1);
	v.push_back(2);v.push_back(3);v.push_back(4);
	vector<int>::iterator i=v.begin();
	vector<int>::iterator j=i+2;cout<<*j<<"";
	i+=3;cout<<*i<<"";
	j=i-1;cout<<*j<<"";
	j-=2;
	cout<<*j<<"";
	cout<<v[1]<<endl;	//output 1

	(j<i)?cout<<"j<i":cout<<"not(j<i)";cout<<endl;	//output 2
	(j>i)?cout<<"j>i":cout<<"not(j>i)";cout<<endl;	//output 3

	i=j;
	i<=J&&j<=i?cout<<"i and j equal":cout<<"i and j not equal";cout<<endl;  //output 4
	j=v.begin();
	i=v.end();
	cout<<"iterator distance end - begin =^ size:"<<(i-j);  //output 5


	return 0;

}

Recommended Answers

All 2 Replies

i<=J&&j<=i?cout<<"i and j equal":cout<<"i and j not equal";cout<<endl; //output 4

Doesn't your compiler say something like this?

Undefined symbol 'J' in function main()

Which would make it easy to find this:

i<=[B]J[/B]&&j<=i?cout<<"i and j equal":cout<<"i and j not equal";cout<<endl; //output 4

I saw that and did not catch it, eyes were tired,
thanx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.