Newby: VC6 errors
Hello,
I am trying to understand why this string concatenation is not
working. Could someone shed some light on this and tell me what I'm
doing wrong?
TIA..
---Errors:---
ParseLineDemo.cpp
C:\ParseLineDemo\ParseLineDemo.cpp(245) : error C2784: 'class
std::reverse_iterator<_RI,_Ty,_Rt,_Pt,_D> __cdecl std::operator +
(_D,const class std::reverse_iterator<_RI,_Ty,_Rt,_Pt,_D> &)' : could
not deduce template argument for '' from 'class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> >'
C:\ParseLineDemo\ParseLineDemo.cpp(245) : error C2676: binary '+' :
'class std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> >' does not define this operator or a conversion
to a type acceptable to the predefined operator
---ParseLineDemo.h---
#include "stdafx.h"
#include <string.h>
#include <vector>
using namespace std;
union POD //Plain Ordinary Data
{
int i;
float f;
};
class DataSegment
{
public:
DataSegment(){}; //default constructor
~DataSegment();
void setHeader(char dH[4]);
void Push(POD p);
string toString();
void Clear(); //empty out the object
private:
char dataHeader[4]; //the name of the segment e.g. S[ or D[
vector<POD> components;
};
---ParseLineDemo.cpp---
....
string DataSegment::toString()
{
string szOutput;
int i;
szOutput = dataHeader;
szOutput = szOutput + "[" //error occurs here
for (i = 0; i < components.size(); i++)
{
szOutput = szOutput + components[i].i + ",";
}
//remove last comma and add closing bracket
szOutput = szOutput.substr(0, szOutput.length() - 1) + "]";
return szOutput;
}
....