|
See here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'm writing a class which is more or less a STL map with a few enhancements, e.g. sending of update notifications. To still have STL like access to the map, I forward the map iterators in my class with public typedefs. The problem is, those typedefs seem to be missing a semicolon where there is definitely none missing;
<br />
#include <map><br />
<br />
template <typename K, typename V><br />
class Repository<br />
{<br />
private:<br />
typedef std::map<K, T> ReposMap;<br />
public:<br />
typedef ReposMap::iterator iterator;
typedef ReposMap::const_iterator const_iterator;
public:<br />
Repository()<br />
{<br />
}<br />
<br />
~Repository()<br />
{<br />
}<br />
<br />
<br />
private:<br />
ReposMap m_objects;<br />
};<br />
MSVC8 gives the following error msgs compiling this code:
Error 2: error C2146: syntax error : missing ';' before identifier 'iterator' 14
Error 3: error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 14
and the same error msgs again for line 15 before 'const_iterator'
I was wondering what the error could be in that few lines of code. Typedefs should be able to work with template parameters, so there shouldn't be an problem, should it?
I'm trying to compile this and some other versions of the same problem for two days now, but I don't have an idea, what could cause the problem, so I'd appreciate any suggestions.
thanks in advance,
Norbert
|
|
|
|
|
sorry, it seems my <'s have been removed.
Here should be the corrected version of the code:
<br />
template <typename K, typename V><br />
class Repository<br />
{<br />
private:<br />
typedef std::map<K, V> ReposMap;<br />
public:<br />
typedef ReposMap::iterator iterator;<br />
typedef ReposMap::const_iterator const_iterator;<br />
public:<br />
Repository()<br />
{<br />
}<br />
<br />
~Repository()<br />
{<br />
}<br />
<br />
private:<br />
ReposMap m_objects;<br />
};<br />
|
|
|
|
|
N-O-R-B-E-R-T wrote: public:
typedef ReposMap::iterator iterator;
typedef ReposMap::const_iterator const_iterator;
Modify this to,
typename ReposMap::iterator iterator;
typename ReposMap::const_iterator const_iterator;
See MSDN documentation for warning C4346 .
|
|
|
|
|
I've had the warnings supressed, and I forgot about that. I'm sorry for posting without reading all errors AND warnings before.
Thanks for your fast help.
Norbert
|
|
|
|
|
N-O-R-B-E-R-T wrote: I've had the warnings supressed, and I forgot about that
You should not ignore warning at all !
|
|
|
|
|
Have a look at reply below, posted by Stephan.
|
|
|
|
|
prasad_som wrote: Modify this to,
typename ReposMap::iterator iterator;typename ReposMap::const_iterator const_iterator;
I assume you mean this:
typedef typename ReposMap::iterator iterator;
typedef typename ReposMap::const_iterator const_iterator;
Steve
|
|
|
|
|
Stephen Hewitt wrote: I assume you mean this:
typedef typename ReposMap::iterator iterator;typedef typename ReposMap::const_iterator const_iterator;
Yes.
|
|
|
|
|
Hi everyone,
I'm having problems deploying C++ applications built with VS.NET 2005 SP1. On my WinXP SP2 machine, the applications run fine, but attempting to run them on Windows Server 2003 yields an error dialog with the text: "This application has failed to start because the application configuration is incorrect..."
This problems has only appeared since installing SP1 for VS, and only seems to affect C++ applications. (Both native and CLR) Does anyone know what the problem could be? My first guess was missing DLLs, but this problem still occurs when I deploy the applications bundled with the VC++ DLLs.
TIA,
Ralph
|
|
|
|
|
Never mind. I found an answer here. Seems I forgot to install the VC8 redist package.
|
|
|
|
|
My application window contains many controls.so it became too large.so i want to hide half part of the window initially.Now when i click button inside my dialog the window shows the hidden half part of the window.How can i scroll the window from left to right with using the button because i don't want scrollbars.
Thanks,
Radhika.
|
|
|
|
|
radhika28 wrote: Now when i click button inside my dialog the window shows the hidden half part of the window.How can i scroll the window from left to right with using the button because i don't want scrollbars.
ScrollWindow, ScrollWindowEx.
|
|
|
|
|
Maybe this[^] or this[^] or this[^] does what you need?
Failure is not an option - it's built right in.
|
|
|
|
|
What would you say is the best way to set a idle timeout on a socket connection?
Artificial Intelligence is no match for Natural Stupidity
No one can understand the truth until he drinks of coffee's frothy goodness. ~Sheik Abd-al-Kadir
I can't always be wrong ... or can I?
|
|
|
|
|
|
The SetTimer() approach given will work. Also depending on your application the TimerQueue[^] library might be more appropriate.
led mike
|
|
|
|
|
hi,
I have Doc/view application I want to get invalidate rectangle value in my ondraw() function.
can any one help me?
Thanks in advance.
Regards,
Rushiraj
|
|
|
|
|
Use m_ps(PAINTSTRUCT) member of CPaintDC class.
void CMyView::OnDraw(CDC* pDC)
{
CPaintDC* dcPain = dynamic_cast<CPaintDC*>(pDC) ;
RECT rcInvalid= dcPain->m_ps.rcPaint ;
}
|
|
|
|
|
|
Hello all,
I have a Rich edit control in my win 32 App.
I am passing one word to rich edit control and I want to change the color of that word in all the places where it occurs in the Rich control.
I am trying with this code
void ColorWords(char* word,HWND hwnd)<br />
{<br />
CHARFORMAT2 cf;<br />
memset(&cf, 0, sizeof(CHARFORMAT2));<br />
cf.cbSize = sizeof(CHARFORMAT2);<br />
cf.dwMask = CFM_BOLD;<br />
cf.dwEffects = CFE_BOLD;<br />
COLORREF clr =RGB(255, 10, 15) ;<br />
cf.dwMask =CFM_COLOR;<br />
cf.crTextColor = clr;<br />
<br />
<br />
FINDTEXTEX findText;<br />
int foundCount = 0;<br />
int foundPos = 0;<br />
int wordLen = lstrlen(word);<br />
<br />
findText.chrg.cpMin = 0;<br />
findText.chrg.cpMax = -1;<br />
findText.lpstrText = word;<br />
<br />
HWND hwndRichEdit = GetDlgItem(hwnd, IDC_FILECONT);<br />
foundPos=SendMessage(hwndRichEdit,EM_FINDTEXT,FR_WHOLEWORD,(LPARAM)&findText);<br />
<br />
while (foundPos != -1)<br />
{<br />
SendMessage(hwndRichEdit,EM_EXSETSEL,0,(LPARAM)foundPos + wordLen);<br />
SendMessage(hwndRichEdit,EM_GETCHARFORMAT,SCF_SELECTION,(LPARAM)cf);<br />
findText.chrg.cpMin = foundPos + wordLen; <br />
foundPos =SendMessage(hwndRichEdit,EM_FINDTEXT,FR_WHOLEWORD,(LPARAM)&findText);<br />
}<br />
}
I am getting the below error can u please tell me what is error ??
Error :-
error C2440: 'type cast' : cannot convert from 'struct CHARFORMAT2A' to 'long'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
|
|
|
|
|
Hi Prasad,
Thanks for the response. I did that changes and its working.
Now no compile time errors,and also I am not getting any out put . I just traced the code using debug .
Till this line no error while (foundPos != -1)
after this statement I am getting
unhanded exception in a.exe (RICHED20.DLL):0XC000005 : Access violation
can u please tell me what is the error ?? is there any problem with send messages ??
|
|
|
|
|
Hi Prasad,
I made the changes
<br />
while (foundPos != -1)<br />
{<br />
CHARRANGE chrRange;<br />
chrRange.cpMin = foundPos-1;<br />
chrRange.cpMax = chrRange.cpMin + wordLen;<br />
SendMessage(hwndRichEdit,EM_EXSETSEL,0,(LPARAM)(&chrRange));<br />
SendMessage(hwndRichEdit,EM_GETCHARFORMAT,SCF_SELECTION,(LPARAM)(&cf));<br />
findText.chrg.cpMin = foundPos + wordLen; <br />
foundPos=SendMessage(hwndRichEdit,EM_FINDTEXT,FR_WHOLEWORD,(LPARAM)&findText);<br />
}<br />
Now i am not getting any debug error or the words are getting colored ??
word color is not getting updated why ?? is there any error in this format statment ??
SendMessage(hwndRichEdit,EM_GETCHARFORMAT,SCF_SELECTION,(LPARAM)(&cf));
|
|
|
|
|
Ho at last ……its working … thanks prasad ……now words are getting colored …
To the color function I am passing the word like if I am passing the word Africa only that particular word will be highlighted. And in the dialog I have one more option like we can give fuzziness ranging from 1 to 5 if we give fuzziness as 1 and search word as Africa , it should high light the words like Africa1 African 0Africa etc and so on …
I want to know is there any possibilities of doing this ???? if yes then which send methods I have use ???
|
|
|
|
|