473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Pointer problem

Trying to load a vector, I got the following messages:
Jan 4 '07 #1
10 1891
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'
Jan 4 '07 #2
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'
Jan 4 '07 #3
Here is the WindDataReceiveBuffer header:
Jan 4 '07 #4
Expand|Select|Wrap|Line Numbers
  1. #ifndef WINDDATARECEIVEBUFFER_H_
  2. #define WINDDATARECEIVEBUFFER_H_
  3.  
  4. #include "windsTableElement.h"
  5. #include <vector>
  6. typedef std::vector< WindsTableElement > WindTable;
  7. WindTable wt_;
  8.  
  9. class WindDataReceiveBuffer
  10. {
  11.  
  12.     static WindDataReceiveBuffer* instance_;
  13.  
  14. protected:
  15.     WindDataReceiveBuffer();
  16.     ~WindDataReceiveBuffer();
  17.     WindDataReceiveBuffer(const WindDataReceiveBuffer&);
  18.     WindDataReceiveBuffer& operator=(const WindDataReceiveBuffer&);
  19.  
  20. public:
  21.     static WindDataReceiveBuffer* Instance();
  22.     void setData(char*, unsigned int);
  23.     WindTable getWindTable();      
  24.  
  25. };
  26.  
  27. #endif /*WINDDATARECEIVEBUFFER_H_*/
  28.  
Jan 4 '07 #5
And the implementation code:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include "WindDataReceiveBuffer.h"
  3.  
  4. WindDataReceiveBuffer* WindDataReceiveBuffer::instance_ = 0;
  5.  
  6. WindDataReceiveBuffer* WindDataReceiveBuffer::Instance()
  7. {
  8.     if (instance_ == 0)
  9.     {
  10.         instance_ = new WindDataReceiveBuffer;
  11.     }
  12.     return instance_;
  13. }
  14.  
Jan 4 '07 #6
Expand|Select|Wrap|Line Numbers
  1. WindDataReceiveBuffer::WindDataReceiveBuffer()
  2. {
  3.  
  4. }
  5.  
  6. WindDataReceiveBuffer::~WindDataReceiveBuffer()
  7. }
  8.  
  9. void WindDataReceiveBuffer::setData(char* inBufr, 
  10.     unsigned int size)
  11. {      
  12.     std::copy(inBufr, inBufr+(size * sizeof(WindsTableElement)), wt_);
  13. }
  14.  
  15. WindTable WindDataReceiveBuffer::getWindTable()
  16. {
  17.     return wt_;
  18. }
  19.  
Jan 4 '07 #7
Ganon11
3,652 Expert 2GB
And the implementation code:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include "WindDataReceiveBuffer.h"
  3.  
  4. WindDataReceiveBuffer* WindDataReceiveBuffer::instance_ = 0;
  5.  
  6. WindDataReceiveBuffer* WindDataReceiveBuffer::Instance()
  7. {
  8.     if (instance_ == 0)
  9.     {
  10.         instance_ = new WindDataReceiveBuffer;
  11.     }
  12.     return instance_;
  13. }
  14.  
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.
Jan 4 '07 #8
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.)
Jan 4 '07 #9
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.
Jan 4 '07 #10
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.
Jan 4 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Carsten Spieß | last post by:
Hello all, i have a problem with a template constructor I reduced my code to the following (compiled with gcc 2.7.2) to show my problem: // a base class class Base{}; // two derived...
5
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current insertion point. In this funtion, the user...
7
by: Mike D. | last post by:
I have a problem with a dynamic library I am developing, but it is really more of a pointer issue than anything else. Hopefully someone here can lend me some assistance or insight into resolving...
10
by: Kieran Simkin | last post by:
Hi, I wonder if anyone can help me, I've been headscratching for a few hours over this. Basically, I've defined a struct called cache_object: struct cache_object { char hostname; char ipaddr;...
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
7
by: Marcelo | last post by:
Hi everybody, I don't understand why I am having a problem in this code. The problem is that my pointer *phist in main method, it is declared. Then I send the pointer to my method, and this...
51
by: Joe Van Dyk | last post by:
When you delete a pointer, you should set it to NULL, right? Joe
2
by: toton | last post by:
Hi, This is continuation of topic pointer & reference doubt. http://groups.google.com/group/comp.lang.c++/browse_thread/thread/df84ce6b9af561f9/76304d7d77f6ccca?lnk=raot#76304d7d77f6ccca But I...
9
by: junky_fellow | last post by:
Hi, To print the pointer using printf(), we convert it to (void *) . printf("%p",(void *)ptr); My question is how printf() determine which type of pointer is passed to it and prints its value...
6
by: worlman385 | last post by:
For pointer and non-pointer initialization of an object like MyCar mycar; MyCar* mycar = new MyCar(); I heard from other people saying if object i create must live outside scape, then I use...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.