Error in a vector

Hi!I am writing a c++ program which uses a vector which contains rows and columns of a table.Unfortunately I got the following error:
IntelliSense: no instance of overloaded function "std::vector<_Ty, _Alloc>::push_back [with _Ty=CCellDescr *, _Alloc=std::allocator<CCellDescr *>]" matches the argument list
argument types are: (const CCellDescr)
object type is: std::vector<CCellDescr *, std::allocator<CCellDescr *>> Here`s the code:

#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<iterator>
using namespace std;

class CCellDescr
{
public:
double m_double_val;
string m_str_val;
int m_row;
int m_col;
char m_cCellType; // 'N' 'S'
static int iSortColumnNum;

CCellDescr(){
m_double_val=0;
m_str_val="";
m_row=0;
m_col=0;

}
CCellDescr(char cCellType, int iColumnNum,int iRowNum,const string strValue,double val)
{

m_col=iColumnNum;
m_row= iRowNum;
m_str_val=strValue;
m_double_val=val;
m_cCellType=cCellType;

}

CCellDescr(const CCellDescr& obj)
{
m_cCellType=obj. m_cCellType;
m_col=obj. m_col;
m_row=obj.m_row;
m_str_val=obj. m_str_val;
m_double_val=obj.m_double_val;
}

double getvalue()const

{
return m_double_val;
}

string getValue()const
{
return m_str_val;

}

int getrow()const
{
return m_row;


}

int getcol()const
{
return m_col;


}

char getType()const
{
return m_cCellType;

}

void setvalue( const double& val)
{
m_double_val=val;

}

void setValue(const string& strValue)
{
m_str_val=strValue;


}

void setrow(const int& row)
{
m_row=row;


}

void setcol(const int& col)
{
m_col=col;


}
void setcelltype(const int& type)
{
m_cCellType=type;

}

};

class CData
{
public:
vector<CCellDescr*> m_Data; // table contains(pointers to a cell)
int m_iColumns; // number of the valid columns in the table


CData(int iColumns )
{
m_iColumns=iColumns;

}

~CData()//destructor
{}

int getcolumns()const
{
return m_iColumns;

}

vector<CCellDescr*> getdata(){
return m_Data;
}

void setCell(const CCellDescr& cell_Data)
{

m_Data.push_back( cell_Data);
}



};

void main()
{
CData cell1(3);
CCellDescr ccell;
cell1.setCell(ccell);
}
1
2
3
void setCell(const CCellDescr& cell_Data)
{  m_Data.push_back( cell_Data);
}

You're trying to push an object (not a pointer) onto a vector of pointers.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/

Topic archived. No new replies allowed.