Here is what I have so far:
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <istream>
#include <string>
#include <vector>
using namespace std;
class dm_energy_vec
{
public:
vector<float> m_energy_dep;
};
int main()
{
const int phantom_size = 50;
int energy_index;
vector<float> xpos;
vector<float> energy;
vector<float> energy_dep (0, phantom_size);
vector<dm_energy_vec> energy_dep_sum;
// Create two vectors: xpos and energy.
for(int i = 0; i < 25; i++)
xpos.push_back(0.325*i);
for(int i = 0; i < 25; i++)
energy.push_back(5.364*i);
//create another vector, energy_index that is the ceiling value of the xpos values
for(int i = 0; i < 25; i++)
{
energy_index = ceil(xpos.at(i));
//use the energy_index values as the index for another vector, energy_dep, which stores the energy values
energy_dep.at(energy_index) = energy.at(i);
//store each energy_dep vector in energy_dep_sum vector which is defined by a class
energy_dep_sum.push_back(energy_dep);
}
};
This program first creates two vectors: xpos and energy. xpos and energy contain floating point values. Next, the energy_index vector is created which contains the ceiling values of the xpos vector. Next, the vector, energy_dep, is created which contains the energy values at index, energy_index. What I am trying to do is to store each energy_dep vector into the energy_dep_sum vector using the class dm_energy_vec. When I try to compile this program there is an error on line 40 which reads the following:
Error 4 error C2664: 'void std::vector<_Ty>::push_back(_Ty &&)' : cannot convert parameter 1 from 'std::vector<_Ty>' to 'dm_energy_vec &&'
Does anybody know what the problem is with my code?