473,327 Members | 2,007 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,327 software developers and data experts.

Pointer problem

Trying to load a vector, I got the following messages:
Jan 4 '07 #1
10 1886
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.