|
I am writing a wrapper for XML in C# at the moment, and one thing that takes a few lines of code normally is to take a node and return the text value, if any, associated with it. node.text simply won't do the job well. By making the function GetNodeValue static, I am able to call it if I have a node kicking around but I don't have an instance of my class. The class essentially becomes a namespace that contains functions which I may have a use for even if I don't have an instance of the class at that point in time, so it saves me building the object needlessly.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Gotcha, I think that pretty much explains it.
Nick Parker
|
|
|
|
|
One of the good uses I've found for static members is factory like functions. If I have a class that I dont' want anybody but me to be able to instanciate I make all of hte constructors private. Then I allow creation through static member functions. This comes in handy sometimes especially in other languages such as C# and Java
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
Sometimes you need a class attribute, which is shared between all instances of the class.
Pavel
Sonork 100.15206
|
|
|
|
|
Pavel Klocek wrote:
Sometimes you need a class attribute, which is shared between all instances of the class.
Could you elaborate?
Nick Parker
|
|
|
|
|
If I have the data in 1.prv and I want embed that data in program while compile.
Can I include like this #include "C:/1.prv"?
Thank you.
|
|
|
|
|
Dunno - have you tried ?
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
hey all. I am working on a single document MFC program and currently have a problem. Under a CFormView document, there is the GetDocument function. Is there any way to use this function or get the same effect in a CDialog document? Any help is appreciated. Thanks.
Brad Jennings
|
|
|
|
|
CYourDoc *pDoc = (CYourDoc *)(((CFrameWnd *)AfxGetMainWnd())->GetActiveView()->GetDocument()); I guess this is what you're after.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
I have a vector with pointers to an object. Now for each object I need to call a function Update(float fTime). Now when I write something like this:
for_each(...begin(), ...end(), mem_fun1(CActor::Update(fTime));
fTime is a valid floating point value in the method which calls this algorithm. This does not compile! I tried a variety of alternatives but none compile. Any suggestion on how to compile this?
Jurgen
|
|
|
|
|
Try with
for_each(...begin(), ...end(), bind2nd(mem_fun(CActor::Update),fTime));
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Is there anyone that knows why the following piece of code does not work as it's supposed to?
void CStomGraphDlg::OnSelectMonthcalendar(NMHDR* pNMHDR, LRESULT* pResult)
{
COleDateTime dtSel;
if(m_ctlMonthCalendar.GetCurSel(dtSel)!=0)
{
MessageBox(dtSel.Format("%x"));
// set current selection
GetDlgItem(IDC_STATIC_SEL)->SetWindowText(dtSel.Format(_T("%x")));
}
else
{
MessageBox(_T("Error getting current selection"), _T("Error"), MB_OK|MB_ICONERROR);
}
*pResult = 0;
}
It is supposed to return the date selection in COleDateTime format but the only time it works is after the program has just started, and you select the current date. After changing the selection it crashes and returns invalid date format or something. GetCurSel should return the selection date, right?
Any help appreciated,
Deian
|
|
|
|
|
Deian,
Have a look at this Same problem I perhaps? Only way I could get round it was with GetCurSel( LPSYSTEMTIME pDateTime ) which seemed to return the right result.
Adam.
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
Thanks, I will try that solution ))
Greetings,
Deian
|
|
|
|
|
Hello there,
I run my program from CD, when my program wants to open the database from CD ... my program crashes
I think it's for strange file( .LDB ) because the database can not make .LDB file beside the access database !
How can i change the .LDB path ?????
Please help me !!!
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
The .LDB file is for record locking. Open the database for exclusive use and no ldb file will be generated. See MSDN KB Q208778 (Access2000) or Q136128 (Access95/97) for more info.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
This seems like a simple question but I just wanted to know peoples thougths on it.
Is it better to load an entire Megabyte file all at once and parse it through memory, or is it better to parse through it a line at a time consuming minimal memory?
I implemented the second method for large file downloads to an embedded system but I would love to hear what others thoughts are on this issue.
Thanks,
Brian
|
|
|
|
|
You can use memory mapped file.
Pavel
Sonork 100.15206
|
|
|
|
|
You should use file mapping for big files. Otherwise, reading a file one line at a time will have the same result as reading the entire file such as in binary mode using C++.
Kuphryn
|
|
|
|
|
Hi.
Is it possible to sort a map *by value* instead of by key? Moreover, is it possible to declare a map that with a custome sorting algorithm that sorts accord to value? If yes, please give a sample of the sorting function. I can create the function object, but I need to know the parameter.
Thanks,
Kuphryn
|
|
|
|
|
You cannot sort a map by value (except in the trivial cases in which key order equals value order). What are you trying to do? If you explain it in more detail maybe we can give an alternative.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Are you sure that you want to use a std::map? Maybe another container is better for your needs?
You could use a std::vector of pairs, and sort this using either first or second.
|
|
|
|
|
A map is a key-value containter. The point of a map is to sort by key and look-up items according to their keys. You may use a second map with first one's values as keys and depending on the situation you use either of them.
Best regards,
Alexandru Savescu
|
|
|
|
|
Okay. Thanks.
The algorithm I am working on a probably simple for most programmers. Nonetheless, I want to come up with my own solution instead of posting it and have someone else solve it.
I have implemented a working solution.
Hey, I always appreciate help from members. Sorry about the late reply. CodeProject server was down yesterday evening.
Kuphryn
|
|
|
|
|
When I set the editbox to read-only, its backgroud color will be gray. Can I set it to another color?
Thanks in advance.
|
|
|
|