The following is snippet from code that I've written:
int n,i,j;
map<int,int>mp;
vector<int>vec;
cin>>n;
for(i=0; i<n; i++)
{
cin>>j;
mp[j]==0? mp[j]=1,vec.push_back(j): mp[j]=1;
}
For the second line inside for loop, CodeBlocks-16.01 version shows the following error:
second operand to the conditional operator is of type 'void', but the third operand is neither a throw-expression nor of type 'void'
But when I change the line to:
mp[j]==0? vec.push_back(j), mp[j]=1: mp[j]=1;
There is no error. What is the issue with following line?
mp[j]==0? mp[j]=1,vec.push_back(j): mp[j]=1;