|
pop out so many errors, which seemed don't even exist:
--------------------Configuration: 12 - Win32 Debug--------------------
Compiling...
StdAfx.cpp
c:\program files\microsoft visual studio\vc98\include\winuser.h(3) : error C2143: syntax error : missing ';' before '.'
c:\program files\microsoft visual studio\vc98\include\winuser.h(3) : error C2501: 'winuser' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\winuser.h(3) : error C2143: syntax error : missing ';' before '.'
c:\program files\microsoft visual studio\vc98\include\winuser.h(27) : error C2143: syntax error : missing ';' before '{'
c:\program files\microsoft visual studio\vc98\include\winuser.h(27) : error C2447: missing function header (old-style formal list?)
c:\program files\microsoft visual studio\vc98\include\winuser.h(7127) : error C2014: preprocessor command must start as first nonwhite space
c:\program files\microsoft visual studio\vc98\include\winuser.h(7474) : error C2001: newline in constant
c:\program files\microsoft visual studio\vc98\include\winuser.h(8267) : error C2014: preprocessor command must start as first nonwhite space
c:\program files\microsoft visual studio\vc98\include\winuser.h(8292) : error C2014: preprocessor command must start as first nonwhite space
c:\program files\microsoft visual studio\vc98\include\winuser.h(8300) : error C2014: preprocessor command must start as first nonwhite space
c:\program files\microsoft visual studio\vc98\include\winuser.h(8309) : error C2014: preprocessor command must start as first nonwhite space
c:\program files\microsoft visual studio\vc98\include\winuser.h(8526) : error C2014: preprocessor command must start as first nonwhite space
c:\program files\microsoft visual studio\vc98\include\winuser.h(8529) : error C2014: preprocessor command must start as first nonwhite space
c:\program files\microsoft visual studio\vc98\include\winuser.h(8534) : error C2014: preprocessor command must start as first nonwhite space
c:\program files\microsoft visual studio\vc98\include\winuser.h(9427) : fatal error C1070: mismatched #if/#endif pair in file 'c:\program files\microsoft visual studio\vc98\include\winuser.h'
Error executing cl.exe.
12.exe - 15 error(s), 0 warning(s)
|
|
|
|
|
I see a BIG DIFFERENT in performance, between the following 2 methoods, WHY IS THAT?:
---------------Method 1-----------------------------
Class
{
Member x
Function()
{
Write to x;
}
}
Main()
{
Call function()
}
--------------Method 2:--------------------------------
Class
{
Function(member x)
{
Write to the member x;
}
}
Main()
{
Member x ;
Call function (x)
}
|
|
|
|
|
Haoman17 wrote: I see a BIG DIFFERENT in performance, between the following 2 methoods,
if the second method is faster, it could be because the constructor or destructor of 'Member' takes a long time.
if the first method is faster, it could be because you're doing a deep copy of 'x' when passing it.
|
|
|
|
|
Could you post the code you used in the testing?
Best,
Jun
|
|
|
|
|
They will execute at the same speed if you pass x by reference in Method 2. Otherwise, if Member is a complex datatype, Method 2 will run slower since it has to copy the value of x into the function before entering the function.
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
|
|
|
|
|
Hello,
I have create a CComboBox with like that and when I click on the droplist it happend nothing but when I use push left or right key the value chang.
CComboBox * pcombo=NULL;
pcombo = new CComboBox;
pcombo->Create(WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST, CRect(x,y,rect.Width(),20), this, i);
How can I create or witch propertie should I use to do what I want to do.
Thank You
AutreChien
|
|
|
|
|
Do you need to create it at runtime? Does changing the (height) value of 20 to something larger make any difference?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thank you , it's work now
AutreChien
|
|
|
|
|
Hi,
I'm developing a NT Service using .NET 2.0, its a multithreaded TCP server, this service will handle connections from many enterprise applications.
The challenge is to avoid a single-point-of-failure. My first idea was create a service instance capable of just redirect incoming calls to service instances which implement the concrete service.
This solution decrease service unavailability risk, but AFAIK real cluster services like App Center uses another approach, it creates a virtual server that can redirect incoming calls to an available server, this approach really solve the single-point-of-failure problem.
I'd like to use the same solution, how it can be done ?
Thanks for any help !
|
|
|
|
|
need (preferably) straight C code to retreive document properties from a microsoft word document. C++ is OK. but prefer C.
i have been looking at other versions, and can't get my head around the various snippets of code published. would like complete functionality.
thanks in advance.
|
|
|
|
|
dannyjoe wrote: would like complete functionality.
How much are you ready to pay for that ?
|
|
|
|
|
See here.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
share the resource like bitmap, dialog box or others.
|
|
|
|
|
Just add the .rc file to both projects (including the resource.h header file). This method may be quick, but it's wrong. You should really create a resource only dll, and link that to both projects.
|
|
|
|
|
Hi all,
I have an application that shows a dialog with a listview control. I added a "Print" button to this dialog (with ID "IDC_PRINT"). Now, all of a sudden, the close button (the cross in the top-right corner) acts as if this print button has been pressed rather than closing the dialog. How do I get things right again?
Thanks in advance for any advice,
William
|
|
|
|
|
Hi again,
Sorry, I should have investigated further. For some reason, Studio decided to define IDC_PRINT with a value of 2 rather than to add it into the normal sequence of IDC values. After doing so manually, things are in order again.
Regards,
William
|
|
|
|
|
|
Hi,
I am trying to apply the sort() algorithm on a vector of structs. I want the vector to be sorted according to one of the struct fields. I see two ways in which this could be done, and neither seems to work.
Here are the struct and the vector:
<br />
struct item_calculation <br />
{<br />
int item_num;<br />
float weight;<br />
float contribution;<br />
float prediction;<br />
};<br />
<br />
vector<item_calculation> found_items;
I want the vector "found_items" to be sorted by the field "prediction".
The first way to do the task is defining a comparison function and sending it do sort() as a parameter:
bool less_than( item_calculation a, item_calculation b ) {<br />
return a.prediction < b.prediction;<br />
}; <br />
.<br />
.<br />
.<br />
sort(found_items.begin(), found_items.end(), less_than);
This results with the errors: "error C3867: 'CCFEApp::less_than': function call missing argument list; use '&CCFEApp::less_than' to create a pointer to member."; "error C2780: 'void std::sort(_RanIt,_RanIt)' : expects 2 arguments - 3 provided"
when using "&CCFEApp::less_than" I get the error: "error C2914: 'std::sort' : cannot deduce template argument as function argument is ambiguous".
The second way to do the task is by overloading the "<" operator:
bool operator<(item_calculation a, item_calculation b) {<br />
return a.prediction < b.prediction;<br />
};
gives: "error C2804: binary 'operator <' has too many parameters".
After changing to:
<br />
bool operator<(item_calculation b) {<br />
return prediction < b.prediction;<br />
};
one gets: "error C2065: 'prediction' : undeclared identifier".
I would apreciate any help.
Thanks,
Avi.
P.S. I am working under Visual Studio 2005.
|
|
|
|
|
I just checked some similar sort code that I use and the only difference is that my sort function takes two const reference params. Try changing your sort function:
bool less_than(const item_calculation& a, const item_calculation& b )
{
return a.prediction < b.prediction;
};
|
|
|
|
|
I have already changed the definition adding the const s and references. this doesn't make a difference.
Avi.
|
|
|
|
|
Avi,
Weird, as I just created a test console app (using VS2005) and it builds without errors:
#include "stdafx.h"
#include <vector>
#include <algorithm>
struct item_calculation
{
int item_num;
float weight;
float contribution;
float prediction;
};
bool less_than(const item_calculation& a, const item_calculation& b)
{
return a.prediction < b.prediction;
};
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<item_calculation> items;
std::sort(items.begin(), items.end(), less_than);
}
|
|
|
|
|
Thanks for the effort, Robert.
This problem buggs me exactly because the code seems to me to be correct.
In my case all the declarations (struct, function) are made inside a class definition, and sort() is called from inside a member fonction. can this make any difference?
|
|
|
|
|
avimitrani wrote: In my case all the declarations (struct, function) are made inside a class definition, and sort() is called from inside a member fonction. can this make any difference?
Yes. Move the overriden operator< outside of your app class and declare it as a friend to your app class.
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;
class MyClass
{
public:
MyClass() { initMe(); }
void sortMe() { sort(found_items.begin(), found_items.end()); }
void showMe() { copy(found_items.begin(), found_items.end(), ostream_iterator<item_calculation>(cout, " ")); }
private:
struct item_calculation
{
int item_num;
float weight;
float contribution;
float prediction;
item_calculation() : item_num(0), weight(0.0), contribution(0.0), prediction(0.0)
{}
item_calculation(int in, float w, float c, float p) : item_num(in), weight(w), contribution(c), prediction(p)
{}
};
vector<item_calculation> found_items;
void initMe()
{
for (int i = 10; i > 0; --i)
{
float f = static_cast<float>(i);
item_calculation ic(i, f, f, f);
found_items.push_back(ic);
}
}
friend bool operator< (const item_calculation& lhs, const item_calculation& rhs);
friend ostream& operator<<(ostream& os, const item_calculation& ic);
};
bool operator< (const MyClass::item_calculation& lhs, const MyClass::item_calculation& rhs)
{
return lhs.prediction < rhs.prediction;
}
ostream& operator<<(ostream& os, const MyClass::item_calculation& ic)
{
os << ic.item_num;
return os;
}
int main()
{
MyClass me;
me.showMe();
cout << endl;
me.sortMe();
me.showMe();
}
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
|
|
|
|
|
Thanks again, Zac
Your suggestion strikes me as the most correct way to do it.
I managed to compile the project by using a different solution:
struct item_calculation
{<br />
int item_num;<br />
float weight;<br />
float contribution;<br />
float prediction;<br />
bool operator<(const item_calculation &b) {<br />
return prediction < b.prediction;<br />
};<br />
};
This should work too, but I'll opt for the friend function option.
Many thanks,
Avi.
|
|
|
|
|
The only problem you will run into is if the item_calculation struct is a private inner class, the opeartor< will be "private", so it won't be able to be used outside the outer class (that is, sort may have issues with it). That goes away if it is a public inner class, or if you override the operators outside the class.
There are other reasons to override binary operators outside the class they operate on, but that goes beyond the scope of this question.
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
|
|
|
|
|