|
George_George wrote: I only want to check which one is new and which one is old.
Then a simple numeric value would work.
George_George wrote: I do not have to use timestamp, right?
Correct.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thank you all the time, DavidCrow!
regards,
George
|
|
|
|
|
I have a string class, where I defined the binary operator '+' in the following ways:
class String:public List<char> {
...
String& operator + (const char[]) const;
String& operator + (const int) const;
friend String& operator +(const char[], const String& );
friend String& operator +(const uint, const String& );
...
}
along with an inherited method from the base class List<type> as follows:
List<TYPE>& operator + (const List<TYPE>& ) const;
When I try to build the project, I get the following error:
error C2678: binary '+' : no operator found which takes a left-hand operand of type 'String' (or there is no acceptable conversion)
I am getting three identical errors from other parts of my program that were written in a similar manner. Does anyone know what this can be attributed to? Thanks,
-Jeff
-- modified at 8:03 Wednesday 16th August, 2006
|
|
|
|
|
The message is issued by the compiler that didn't find a match that
satisfy the RIGHT operand, you said nothing about.
Admitting it was another "String", the reasons is because, when you
override a name all definition pertinent to that
name are lost in the inner scope.
In fact, since you override operator+ in String ,
any underlying operator+ in List
are anymore visible while accessing String .
You should redeclare, in String ,
friend String& operator+(const String& s)
{ return List<char>::operator+(s); }
along with the other operator+ variants you
already declared.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
I attempted that piece of code, and received an error like "Using non-static member of List<char>"
However, your response inspired me to try other things that were close to your solution, and the one that finally made the problem go away was simply to redefine the operation in the string class like:
String& String::operator +(const String&) const { <code here> }
I guess what I am confused about, is the following: In the following code, why isn't the List operator + equivalent to the String operator + as defined above from the compiler's perspective? Is there a way to make them equivalent, perhaps by using another method of definition?
template <class TYPE>
class List<TYPE> {
...
public:
List<TYPE>& operator +(const List<TYPE>& ) const;
...
}
class String:public List<char> {
}
Thanks,
-Jeff
-- modified at 14:36 Wednesday 16th August, 2006
|
|
|
|
|
Skippums wrote: I attempted that piece of code, and received an error like "Using non-static member of List<char>"
OOPS: In fact I did a mistake in writing the function: List::operator+ returns a List, not a String as i did.
Skippums wrote: Is there a way to make them equivalent, perhaps by using another method of definition?
No, that's basic C++ scope overriding.
class A
{
void f1(int) { ... }
void f1(double) { ... }
};
class B: public A
{
void f1(double) { ... }
};
It is not B::f1(double) overriding A::f1(double) .
It is B::f1 masking A::f1 , whatever f1 represent in A or B .
You can have as many f1 variant you want in A , but as you declare f1 to do whatever thing in B , f1 in A is "masked, when working with B scope".
-- modified at 11:32 Thursday 17th August, 2006
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
i have a problem in my progress bar (attached in a Dialog) everytime the dialog lost its focus or became inactive its switches to sort of not responding mode, thats why you will not be able to know or determine the status or the %finish of the progress bar ..
|
|
|
|
|
Are you running your progress bar using a separate thread ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
It is not the progress bar which is responsible of that. The problem is that you probably start a lenghty process in the main thread and in that case, your GUI is unable to process messages (thus doesn't respond to user actions).
If you want to avoid that, you have to start a new thread in which you will compute your lenghty operation.
|
|
|
|
|
I have taken a char ch; variable. I have opened a file in read mode and reading each character at a time and printing it into a text box.
It prints evety character except 'tab'. Its printing a pipe sysmbol instead of giving a tab space. How to solve it?
Please Help.
Thank you.
KIRAN PINJARLA
|
|
|
|
|
How do you know that it is a tab character (I mean in what editor does the char be displayed as a tab?) ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
check for ^I for tab space (if any tab is present)
never say die
|
|
|
|
|
To my knowledge, edit controls do not support tab characters. I suggest that you replace each tab character encountered with an appropriate number of spaces.
Another idea would be to use a rich edit control.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi
I have been doing a bit of work with 'wav' files, and in the format the number of channles can be defined. I have only found mono\stereo files so far - is it possible to have 4 channel 'wav' files (quadraphonic)?
Even better would be 5.1 surround sound (or are the extra (Centre & Bass)channels derived from the L\R mix?)
If it is possible, can anyone point me in the right direction to get a sample 4 channel 'wav' file so I can have a play?
Sorry - probably not the right place to ask this, but not sure where to
Regards
69 Bay
-- modified at 6:36 Wednesday 16th August, 2006
|
|
|
|
|
Hi All,
When we include a class, the wizard creates two files (.h and .cpp) in the class's name. The .cpp file starts with like this:
#ifndef _FILE1_H
#define _FILE1_H
#include "File1.h"
#endif
Hope this is a way to avoid including the file (.h) more than once in the application. How this .cpp file is getting related with its corresponding .h file? Because, we include only .h file.
Kindly let me know that how can compare this with "# pragma once" and more about "pragma".
Thanks in advance,
Sarvan AL
*** Live Life To Its Fullest ***
|
|
|
|
|
Sarvan AL wrote: Hope this is a way to avoid including the file (.h) more than once in the application
Yes, it is. However, the #ifdef/#define##endif should normally be located inside File1.h, and not where it is called.
In File1.h:
#ifndef _FILE1_H
#define _FILE1_H
.. here the declarations
#endif
In the .cpp
#include "File1.h"
Otherwise, you need to reproduce the ifndef/endif block for each include of the File1.h, which is no good practice (unless you have some hardware limitation, like the h file is located on some network that is lengthy to be accessed and that the simple fact of going inside the include lasts 5 seconds or more).
#pragma are directive to the precompiler, e.g. the software that runs one time through the code before the compiler. It replaces all occurences of #defines with their real value, copies the content of includes inside the cpp file, etc..
The precompiler can be given some directives using #pragma, such as #pragma disable(warning:1020) which disables warning 1020. Meaning and sometimes existence of pragmas depends on the compiler.
#pragma once is a directive that (for visual c++, but also other compiler) says that the file in which it is located must only be included once. It is equivalent to the code block I've provided you with.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
Hi Rage,
Thank you for your detailed explanation.
Sarvan AL
*** Live Lift To Its Fullest ***
|
|
|
|
|
Adding to Rage explanation on #pragma once, the header file is scanned only once(internally it is maintained in a table)where as
Rage wrote: #ifndef _FILE1_H
#define _FILE1_H
.. here the declarations
#endif
if the header file is included more than once in a .cpp file,it is scanned that no times
-- modified at 8:04 Wednesday 16th August, 2006
-- modified at 8:05 Wednesday 16th August, 2006
never say die
|
|
|
|
|
Hi all,
For some reason my project does not kick in the compiler when I make changes to the code during debug. It used to be fine on VC++ 6, I recently moved the project to VC++ 8.
Has anyone else experienced this? I checked all the debug settings (both in project and IDE), nothing seems to make any difference. New projects allow me to debug with edit and continue fine.
Any suggestions are more than welcome.
All the best,
Tony.
|
|
|
|
|
I have created a class with the following defined:
friend CStrTemp& operator += ( CStrTemp& i, const CStrTemp& s );
and then:
template<class t=""> CStrTemp<t>& operator += ( CStrTemp<t>& i, const CStrTemp<t>& s ) {
///code and return
}
Everything compiled but when it tries to create the executable it throws up the followinf error:
CString.obj : error LNK2019: unresolved external symbol "class CStrTemp<char> & __cdecl operator+=(class CStrTemp<char> &,class CStrTemp<char> const &)" (??Y@YAAAV?$CStrTemp@D@@AAV0@ABV0@@Z) referenced in function "class CString __cdecl operator+(char,class CString const &)" (??H@YA?AVCString@@DABV0@@Z)
Any help would be appreciated as I just cannot understand why it is not working.
|
|
|
|
|
What is CStrTemp ? Is it derived from something ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
ajisthekingofpop wrote: unresolved external symbol...referenced in function "class CString __cdecl operator+(
What does the operator+ method look like?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
There are a few problems here.
First, depending on your compiler, some versions of MFC's CString have a hidden class called CStrTemp. Thus, defining your own class with the same name can cause problems (one of the reasons MFC should have put its stuff in a namespace, and the reason you should do the same).
Second, you defined the function as: friend CStrTemp& operator += ( CStrTemp& i, const CStrTemp& s ); , but implemented it as template CStrTemp& operator += ( CStrTemp& i, const CStrTemp& s ) (I'm assuming you just mistyped the <> signs and that the template declaration should actually read template<class T>). If you defined the class as a template, that will work, but you will need to declare it similar to the following:
friend CStrTemp<T> operator+=(CStrTemp<T>& i, const CStrTemp<T>& s)
and implement it as
template<class T><br />
CStrTemp<T>& operator+=(CStrTemp<T>& i, const CStrTemp<T>& s) {...}
Put your code in a namespace and fix your template declarations and this should clear some things up.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: some versions of MFC's CString have a hidden class called CStrTemp
Now this is interesting. Thanks for sharing it.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
hello all
I am searching for MFC XP Explorer Bar like.
I found an OCX control called vbAccelerator Explorer Bar Control
I tried to use this control inside my MFC application but visual studio 2003 didn't extracted all the required interfaces to deal with the control.
I added the control to the project by adding new class from activeX control.
I would like to know how to add this OCX to my MFC project right
your help is so much appreciated
Hesham
|
|
|
|