C
Chandra Shekhar Kumar
introduce a public member function like getVal for getting the value i then call this
function in write_row2database
function in write_row2database
Hi,
I have a template class that looks like:
template <class T>
class Update
{
friend otl_stream& operator<<
(otl_stream&, const shared_ptr<typename T::row>&);
friend ostream& operator<<
(ostream&,const shared_ptr<typename T::row>&);
friend struct write_row2database;
[snip]public: [snip]
struct write_row2database {
void operator()(val& aVal) {
// (Update<T>).i << aVal;
// !!!!! the problem !!!!!
// i is (private) member of template class, how to address ?
}
Hi Rob, the forward declaration did not help me.Rob Williscroft said:porschberg wrote in
Hi,
I have a template class that looks like:
template <class T>
class Update
{
friend otl_stream& operator<<
(otl_stream&, const shared_ptr<typename T::row>&);
friend ostream& operator<<
(ostream&,const shared_ptr<typename T::row>&);
// insert this:
struct write_row2database;
friend struct write_row2database;
/* without the inserted forward declation the
write_row2database here referes to ::write_row2database
[snip]public: [snip]
struct write_row2database {
void operator()(val& aVal) {
// (Update<T>).i << aVal;
// !!!!! the problem !!!!!
// i is (private) member of template class, how to address ?
}
HTH
Rob.
porschberg said:Hi,
I have a template class that looks like:
template <class T>
class Update
{
friend otl_stream& operator<< (otl_stream&, const shared_ptr<typename T::row>&);
friend ostream& operator<< (ostream&, const shared_ptr<typename T::row>&);
friend struct write_row2database;
public:
typedef shared_ptr<typename T::row> ROW;
typedef typename vector<ROW>::iterator iter;
typedef typename vector<ROW>::value_type val;
...
struct display_row {
void operator()(val& aVal) {
cout << aVal;
}
};
struct write_row2database {
void operator()(val& aVal) {
// (Update<T>).i << aVal;
// !!!!! the problem !!!!!
// i is (private) member of template class, how to address ?
}
...
bool flush(string& error)
{
for_each(v.begin(), v.end(), display_row()); //works
for_each(v.begin(), v.end(), write_row2database());
}
private:
...
vector<ROW> v;
otl_nocommit_stream i;
...
};
My question:
How can I write to i inside write_row2database ,
what is the correct syntax?
I declared
friend struct write_row2database;
and there exist a operator overloading for "otl_stream<<theROW".
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.