Pointer problem | Member | | Join Date: Nov 2006 Location: Houston, Texas
Posts: 46
| | |
Trying to load a vector, I got the following messages:
| | Member | | Join Date: Nov 2006 Location: Houston, Texas
Posts: 46
| | | re: Pointer problem
d:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algobase.h:247: error: no match for 'operator*' in '*__result'
| | Member | | Join Date: Nov 2006 Location: Houston, Texas
Posts: 46
| | | re: Pointer problem
d:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algobase.h:249: error: no match for 'operator++' in '++__result'
| | Member | | Join Date: Nov 2006 Location: Houston, Texas
Posts: 46
| | | re: Pointer problem
Here is the WindDataReceiveBuffer header:
| | Member | | Join Date: Nov 2006 Location: Houston, Texas
Posts: 46
| | | re: Pointer problem - #ifndef WINDDATARECEIVEBUFFER_H_
-
#define WINDDATARECEIVEBUFFER_H_
-
-
#include "windsTableElement.h"
-
#include <vector>
-
typedef std::vector< WindsTableElement > WindTable;
-
WindTable wt_;
-
-
class WindDataReceiveBuffer
-
{
-
-
static WindDataReceiveBuffer* instance_;
-
-
protected:
-
WindDataReceiveBuffer();
-
~WindDataReceiveBuffer();
-
WindDataReceiveBuffer(const WindDataReceiveBuffer&);
-
WindDataReceiveBuffer& operator=(const WindDataReceiveBuffer&);
-
-
public:
-
static WindDataReceiveBuffer* Instance();
-
void setData(char*, unsigned int);
-
WindTable getWindTable();
-
-
};
-
-
#endif /*WINDDATARECEIVEBUFFER_H_*/
-
| | Member | | Join Date: Nov 2006 Location: Houston, Texas
Posts: 46
| | | re: Pointer problem
And the implementation code: - #include <iostream>
-
#include "WindDataReceiveBuffer.h"
-
-
WindDataReceiveBuffer* WindDataReceiveBuffer::instance_ = 0;
-
-
WindDataReceiveBuffer* WindDataReceiveBuffer::Instance()
-
{
-
if (instance_ == 0)
-
{
-
instance_ = new WindDataReceiveBuffer;
-
}
-
return instance_;
-
}
-
| | Member | | Join Date: Nov 2006 Location: Houston, Texas
Posts: 46
| | | re: Pointer problem - WindDataReceiveBuffer::WindDataReceiveBuffer()
-
{
-
-
}
-
-
WindDataReceiveBuffer::~WindDataReceiveBuffer()
-
{
-
}
-
-
void WindDataReceiveBuffer::setData(char* inBufr,
-
unsigned int size)
-
{
-
std::copy(inBufr, inBufr+(size * sizeof(WindsTableElement)), wt_);
-
}
-
-
WindTable WindDataReceiveBuffer::getWindTable()
-
{
-
return wt_;
-
}
-
|  | Moderator | | Join Date: Oct 2006 Location: New York, United States of America
Posts: 3,428
| | | re: Pointer problem Quote:
Originally Posted by PaperPilot And the implementation code: - #include <iostream>
-
#include "WindDataReceiveBuffer.h"
-
-
WindDataReceiveBuffer* WindDataReceiveBuffer::instance_ = 0;
-
-
WindDataReceiveBuffer* WindDataReceiveBuffer::Instance()
-
{
-
if (instance_ == 0)
-
{
-
instance_ = new WindDataReceiveBuffer;
-
}
-
return instance_;
-
}
-
When you define instance_ for the first time (your first line of code here), don't include the WindDataReceiveBuffer* before the WindDataRetrieveBuffer::instance_ declaration. Including this makes it seem like a function which would be returning a variable of type WindDataReceiveBuffer*, which works for your Instance() function, but not a static variable declaration.
| | Member | | Join Date: Nov 2006 Location: Houston, Texas
Posts: 46
| | | re: Pointer problem
It seems I need to overload the operators ++ and * for the pointer __result.
Can you help?
(Sorry for using so many posts, but it is the only way I could get all the code in.
Refer to the "Incrementing a pointer" thread for the windsTableElement class code.)
| | Member | | Join Date: Dec 2006
Posts: 38
| | | re: Pointer problem
the third argument to std::copy must be an output iterator, not an object. So, you can use a pointer, or an actual iterator class, etc. Refer to the std::copy documentation for more info.
| | Member | | Join Date: Nov 2006 Location: Houston, Texas
Posts: 46
| | | re: Pointer problem Quote:
Originally Posted by Ganon11 When you define instance_ for the first time (your first line of code here), don't include the WindDataReceiveBuffer* before the WindDataRetrieveBuffer::instance_ declaration. Including this makes it seem like a function which would be returning a variable of type WindDataReceiveBuffer*, which works for your Instance() function, but not a static variable declaration. The static member variable instance_ contains a pointer to an instantiation of WindDataReceiveBuffer, making sure using routines can only construct one of them.
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|