compilation errors

  • Thread starter Thread starter ravinderthakur
  • Start date Start date
R

ravinderthakur

class Party{
public:
double averageNames(int n, int personA[], int personB[]){
vector<set<int>> personsKnown;
//vector< set<int> > personsKnown;
}
};

int main(){
Party p;
return 0;
}


can anybody plz explain me why the code dosn't compile on msvc6 wheere
as the line that is commented compiles perfectly.note the only
difference between the two is of the spaces
around <>.


thanks
rt
 
class Party{
public:
double averageNames(int n, int personA[], int personB[]){
vector<set<int>> personsKnown;
//vector< set<int> > personsKnown;
}
};

int main(){
Party p;
return 0;
}


can anybody plz explain me why the code dosn't compile on msvc6
wheere as the line that is commented compiles perfectly.note the only
difference between the two is of the spaces
around <>.

Because that's the way the C++ standard says it's supposed to work. When you
have nested template-id's, you have to put whitespace between the closing >
in order to have it parse correctly, Without the space, it parses as a
right-shift operator.

The C++ committee has proposed changing the parsing rules to allow
constructs such as the above to compile without the whitespace, but that
recommendation is not part of any standard yet. Nonetheless, VC++ 8.0 (VS
2005) in fact implements the new rule and would compile your code as
originally written.

-cd
 
Back
Top