Hello:
This is my first time here so I hope I am doing this correctly. I am trying to push a vector object into a vector (I think). Here is my code (header file first) but it's only part of the code. Hope this is enough to make sense. I am getting the error:
[CODE=cpp]#include "IrrigationComp onent.h"
#include <vector>
#include <string>
using namespace std;
// This is IrrigationEstim ator.h
class IrrigationEstim ator
{
private:
vector<Irrigati onComponent> vComp;
vector < vector<Irrigati onComponent> > vItems;
string companyName, busName;
public:
IrrigationEstim ator();
bool ReadData();
string WriteInvoice();
};
// This is my read function and where I am getting the error. See below (line 53).
bool IrrigationEstim ator::ReadData( )
{
string filename;
ifstream input;
input.open("Job .txt");
if(!input)
{
return false;
}
string component;
string type;
float gph;
float cost;
int required;
getline(input, companyName);
while(!input.eo f())
{
int i = 0;
getline(input, component);
getline(input, type);
input >> gph;
input >> cost;
input >> required;
input.ignore();
vector<Irrigati onComponent> component;
vector<Irrigati onComponent> type;
vector<Irrigati onComponent> gph;
vector<Irrigati onComponent> cost;
vector<Irrigati onComponent> required;
vItems.push_bac k(component);
(this being line 53) vComp.push_back (vItems);
vItems.push_bac k(type);
vItems.push_bac k(gph);
vItems.push_bac k(cost);
vItems.push_bac k(required);
i++;
}
input.close();
return true;
}[/CODE]
Thank you for any and all help.
This is my first time here so I hope I am doing this correctly. I am trying to push a vector object into a vector (I think). Here is my code (header file first) but it's only part of the code. Hope this is enough to make sense. I am getting the error:
Code:
IrrigationEstimator.cpp c:\documents and settings\developer\desktop\c++ ii\jacksonp5\jacksonp5\irrigationestimator.cpp(53) : error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'std::vector<_Ty>' to 'const IrrigationComponent &' with
#include <vector>
#include <string>
using namespace std;
// This is IrrigationEstim ator.h
class IrrigationEstim ator
{
private:
vector<Irrigati onComponent> vComp;
vector < vector<Irrigati onComponent> > vItems;
string companyName, busName;
public:
IrrigationEstim ator();
bool ReadData();
string WriteInvoice();
};
// This is my read function and where I am getting the error. See below (line 53).
bool IrrigationEstim ator::ReadData( )
{
string filename;
ifstream input;
input.open("Job .txt");
if(!input)
{
return false;
}
string component;
string type;
float gph;
float cost;
int required;
getline(input, companyName);
while(!input.eo f())
{
int i = 0;
getline(input, component);
getline(input, type);
input >> gph;
input >> cost;
input >> required;
input.ignore();
vector<Irrigati onComponent> component;
vector<Irrigati onComponent> type;
vector<Irrigati onComponent> gph;
vector<Irrigati onComponent> cost;
vector<Irrigati onComponent> required;
vItems.push_bac k(component);
(this being line 53) vComp.push_back (vItems);
vItems.push_bac k(type);
vItems.push_bac k(gph);
vItems.push_bac k(cost);
vItems.push_bac k(required);
i++;
}
input.close();
return true;
}[/CODE]
Thank you for any and all help.
Comment