Z
zigler
Доброго времени суток!
Подскажите, как решить проблему с присваиванием значения std::string в int.
Выдает ошибку
Compiling...
testsss.cpp
E:\files=study\kurs V\Deutschland\Forschungsprojekt\cpptest\testsss\testsss.cpp(60) : error C2440: 'type cast' : cannot convert from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'int'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
testsss.exe - 1 error(s), 0 warning(s)
Подскажите, как решить проблему с присваиванием значения std::string в int.
Код:
// testsss.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
std::string ***LNodeType_DO_attr;
class CDA_Quality {
public:
std::string validity;
std::string overflow;
int timeout;
CDA_Quality();
};
CDA_Quality::CDA_Quality(){}
class CDC_INC {
public:
CDA_Quality q;
CDC_INC();
};
CDC_INC::CDC_INC(){}
class LN_ZBAT {
public:
CDC_INC EEHealth; //External equipment health
LN_ZBAT();
};
LN_ZBAT::LN_ZBAT(){}
int main(int argc, char* argv[])
{
int h,k,p;
LNodeType_DO_attr = new std::string **[5];
for(h=0;h<5;h++)
{
LNodeType_DO_attr[h] = new std::string *[5];
for(k=0;k<5;k++)
{
LNodeType_DO_attr[h][k] = new std::string [5];
for(p=0;p<5;p++)
LNodeType_DO_attr[h][k][p]="";//test
}
}
LN_ZBAT battery1;
LNodeType_DO_attr[1][3][2] = "kkkkk";
std::string ppp;ppp = "dddd";
battery1.EEHealth.q.validity = ppp;
battery1.EEHealth.q.overflow = LNodeType_DO_attr[1][3][2];
battery1.EEHealth.q.timeout = (int)LNodeType_DO_attr[1][3][2];
cout << battery1.EEHealth.q.validity << endl;
cout << battery1.EEHealth.q.overflow << endl;
cout << battery1.EEHealth.q.timeout << endl;
return 0;
}
Выдает ошибку
Compiling...
testsss.cpp
E:\files=study\kurs V\Deutschland\Forschungsprojekt\cpptest\testsss\testsss.cpp(60) : error C2440: 'type cast' : cannot convert from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'int'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
testsss.exe - 1 error(s), 0 warning(s)