|
The problem is that when you return something from a function (for example your GetValue function), a copy of your object will be made (you don't return the object itself but a copy). So in your case, passing it by reference would mean that the function (OnLoseFocusDate) will probably want to modify it. But in your case it is totally useless because the object is lost after the function is called (so, the modifications are lost).
One way to do it is to return a reference to your object in the GetValue function:
Date& NewDate::GetValue(void)<br />
{<br />
if (::IsWindow(this->m_hWnd) && GetFocus() == this )<br />
{<br />
if( m_dateFormat == shortFormat )<br />
{<br />
SetError(!IsValid());<br />
}<br />
}<br />
<br />
return m_value;<br />
<br />
<br />
}<br />
But honnestly, I don't really find this very elegant...
|
|
|
|
|
minkowski wrote: Date xx = m_jdtTerminationDate.GetValue();
OnLoseFocusDate(xx);
A Reference is in effect, a Compiler Generated and Guaranteed Pointer. Unlike Ordinary Poiners, they cannot be NULL, and in most cases, when you try to do something daft, the compiler will object. This happened in this case! A Reference implicitly points to a value in memory. The result of a Function is essentially not a value in memory, so the compiler objects, It is WRONG!
Your Second attempt works, because the reference is an implicit pointer to xx
LateNightsInNewry
|
|
|
|
|
hi,
I want to change the CLSID for an existng class .That is,i want to use the features of a class by giving different name and different CLSID to it.In which application .rgs file is generated.
Thanks in advance
Siddharth
|
|
|
|
|
siddharthsan wrote: I want to change the CLSID for an existng class .
This is bad idea. Why you want to do this ?
siddharthsan wrote: That is,i want to use the features of a class by giving different name and different CLSID to it
What is your problem then ?
|
|
|
|
|
Hello, tell as it is possible to catch occurrence of windows in the another's program, and then to block their occurrence. If it is possible an example. Thank.
-- Am be back --
|
|
|
|
|
Not sure what you want as your post is not very clear but it sounds like you may want to setup a WH_CBT hook.
Look up SetWindowsHookEx() in MSDN, payiny attention to the WH_CBT hook ID and the CBTProc hook procedure. Also see this article[^] on using global hooks.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Hi
I am reading Linkers and Loaders book. It says: "Linker binds more abstract names to more concrete names, which permits programmers to write code using the more abstract names"
I tried a piece of code:
<br />
#include <iostream><br />
using namespace std;<br />
<br />
int main()<br />
{ int x = 0; <br />
foo(x);<br />
return 0;<br />
}<br />
This code tries to use foo function which is not defined anywhere. So I expect VS2005 gives me linker error but it gives me compile-time error.
Why doesnt it give me linker-time error? How must i change code so it gives me linking-time error?
Thanks
|
|
|
|
|
the linker works AFTER the compiler, so if the later cannot compiler, why do you bother ?
you will have a linker error if you define the function in another .cpp file, but don't provide it then
the compiler expects the declaration of a function only. the linker needs the whole body, so if you don't declare the function, you'll face a compiler error
|
|
|
|
|
Because your compiler first check if the function is declared somewhere. It is needed, that's why you need to include files in your cpp files.
What you could do is abuse the compiler in this way: declare the function (provide a functino prototype) but don't define it (no function body).
#include
using namespace std;
void foo(int);
int main()
{ int x = 0;
foo(x);
return 0;
}
In this way the compiler sees that the function exists so it won't complain. But the linker will complain because you didn't provide a body.
|
|
|
|
|
In order to see the linker error all you have to do is
declaring your function without it's definition like this:
<br />
#include <br />
using namespace std;<br />
<br />
void foo(int x);
<br />
int main()<br />
{ int x = 0; <br />
foo(x);
return 0;<br />
}<br />
<br />
|
|
|
|
|
How to remove this 2px line on the top of ReBar control? I've found a RBS_BANDBORDERS style using spy++ but removing this style does not help (neither by calling CReBar::Create(this,0) nor by CReBar::ModifyStyle(RBS_BANDBORDERS,0) - even without this style control still has a line on the top.
Any idea how to disable this line?
Thanks in advance!
|
|
|
|
|
I am having some difficulty passing an array. If someone can shed some light here, I would appreciate it greatly.
void testFunction(int, int, bool, int, int, int [ ], char);
<br />
void testProgram()<br />
{<br />
int testCaseArray1[ 9 ] = { 500, 250, 375, 438, 469, 485, 493, 497, 499 };<br />
char choice1 = 'Y';<br />
<br />
testFunction(0, 0, false, 499, 9, testCaseArray1, 'Y');<br />
}<br />
<br />
void testFunction(int myGuess1, int myGuessCount1, bool myBool, int myInt1, int myInt2, int myArray[ ], char myChar='Y')<br />
{<br />
int num1 = myInt1;<br />
int arraySize1 = myInt2;<br />
int guess1 = myGuess1;<br />
int testCaseArray1[ arraySize1 ];
int guessCount1 = 0;<br />
char choice1 = myChar;<br />
bool correctAnswer1 = myBool;
|
|
|
|
|
You should declare your function this way:
void testFunction(int, int, bool, int, int, int*, char);
There is another thing wrong in your program. This line:
int testCaseArray1[ arraySize1 ];
You cannot declare an array this way (arraySize1 is not a constant). You need to dynamically allocate your array:
int* testCaseArray1 = new int[arraySize1];
And don't forget to delete it when you don't need it anymore.
I would suggest that you take a look at container classes from the STL. It might be hard to understand for a beginner but it solves a lot of problems (memory management and so on).
|
|
|
|
|
OK, but where is your question?
ericelysia wrote: int testCaseArray1[ arraySize1 ];
That won't work because you have to initialize your array with constant expressions. So the array should be defined like this: int testCaseArray1[5];
If you want to initialize different size arrays you have to use
new operand with pointer:
int mySize;<br />
mySize=5;<br />
int *testCaseArray1=new int[mySize]; . When the array initialized with new operand is no longer needed you have to delete it with delete operand: delete [] testCaseArray1;
|
|
|
|
|
I have created a package for my project using visual studio installer , package created successfully. While creating package I have added all required files from dll and also from exe, related files.
I am trying to install the package in a system which does not have Visual Studio,
While I am installing the package I am getting error
Error 1904: module c:\ programming files \ DemoSoft\Demo.dll failed to register HRESULT 2147024770 , contact your support personal
|
|
|
|
|
Can anyone give Video tutorial of VS2005 IDE, VC++ - MFC-Win32- Application tutorial.
|
|
|
|
|
This is a very broad subject that simply cannot covered in a single post. The best way for you to learn is either learn by yourself or buy a good book on the subject (or find free tutorials on the web).
|
|
|
|
|
Cedric,
I am familiar with VC 6.0-IDE, MFC, Win32 etc.
What i am looking for is some good video which explain VS 2005 IDE and using MFC, ATL & other new stuffs of VS 2005
|
|
|
|
|
No such video can explain you each and everything that is new. Buy a book. Nothing else will help you.
Never injure a friend, even in jest.
- Marcus Tullius Cicero
|
|
|
|
|
If you are familiar with VC6 and the MFC, then you shouldn't have troubles to move to VS 2005. There are some slight changes in the MFC but they are minor. And the IDE is not very difficult to understand once you understand VC6.
|
|
|
|
|
|
That's right! Why did I forget this
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
apparently, some idiots didn't like it
|
|
|
|
|
|
Do you want us to create the video for you?
Try GOOGLE![^]
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|