|
Can anyone please recommend a book that is a good guide for beginners to the STL Library. I purchased one book that was supposedly for beginners, the C++ Standard Template Library, and it is so confusing i cant understand it. I would appreciate someone's help with this.
|
|
|
|
|
The book you've bought is the standard reference on the topic. However, there are lots of more elementary texts on the topic. There are also heaps of tutorials on the web ( I wrote a few on this site ). Work through the stuff on CP, then go back to your book.
And, in future, managed C++ means .NET C++, which does not include STL. Use the Visual C++ forum, if you're not using Managed C++ or C++/CLI.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
thanks for the advice. Can you please reference an elementary text on the stl library. I cant seem to find a good tutorial on the web. So there are some on this sight? I would appreciate any help you can give me. Thanks much
Seth Isaacks
|
|
|
|
|
|
Is there any way I coud manage a connection to an mdb database without using ODBC?Because I'm making a small program to store info like phone numbers and such, but I would rather not having to rely on the user having the ODBC for mdb databases, and I've been told that I can manage the connection by only adding a few things to the project, and no need to use ODBC.
I would appreciate any help you could give me.
|
|
|
|
|
Well, as you're asking in the managed C++ forum, I guess you can use the .NET framework classes for database connections. If you posted in the wrong forum, then I'm not sure what your options are, but you should move the question where it belongs, in order to find out.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
No, I actually don't use .NET, I was told that I could access an mdb db from my app by only adding some library to it, and I'm pretty sure it was not a .NET library...
|
|
|
|
|
can anyone walk me through the sequence of events in the following code execution? thank you.
main()
{
int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf(“%d%d\n”,x,y);
in my guess this is what happens...
x = 20; y = 35;
x = 35 + 20; y = 35+1;
x = 35 + (20+1);
x = 56; y = 36;
y = 37 + 57; x = 57;
x = 57; y = 94;
so output is: 5794
i got it printing 5794 but is my analysis correct? thank you
|
|
|
|
|
As i see
x=20; y=35;
x = (35+1) + (20+1) // y has nev value 36
x = 57
y = (36+1) + (57+1);
y = 95;
y++ // this is add 1 to y;
++y // this 1+y, but doesn't increase y for 1.
ps: You are posting in wrong forum, you shoud Visual c++
|
|
|
|
|
bsaksida wrote: ++y // this 1+y, but doesn't increase y for 1.
|
|
|
|
|
int y=1;
x = ++y; //x is 2, y is 1;
x = y++//x is 2, y is 2;
y++; // increase y by 1
|
|
|
|
|
bsaksida wrote: x = ++y; //x is 2, y is 1;
No ! y is 2 here,too. And 2 will be assigned to x.
bsaksida wrote: y++; // increase y by 1
y will become 3 here.
|
|
|
|
|
j11Software wrote: x=y++ + x++;
Here, x(20) is added to y(35) and assigned to x(55). And then incremented(++) with 1 ie.e x is now 56. Y is incremented to 1. Y is 36 now.
j11Software wrote: y= ++y + ++x;
x(56) is incremented for 1 now x is 57. y is incremented for 1. Y is 37 now. Both are added to eqate to y. i.e. y is 94 now.
|
|
|
|
|
Very close.
This is the C equivalent of what the Microsoft compiler produces:
x = 20; y = 35;
x = y + x; // 35 + 20 = 55
x = x+1; // 56
y = y+1; // 36
y = y+1; // 37
x = x+1; // 57
y = y + x; // 94
I would like to note that you should not write code like "y = y++ + x++" because the results are undefined by the language. That is the results of a statement like "x = x++" is considered undefined and it is up to the compiler vendor to decide how to implement it.
The following C equivalent code may be produce by a different compiler:
x = 20; y = 35;
tx = x+1; // 21
ty = y+1; // 36
x = y + x; // 35 + 20 = 55
x = tx; // 21 (unexpected result)
y = ty; // 36
y = y+1; // 37
x = x+1; // 22
y = y + x; // 59
One other thing I would like to point out is that other languages, that have the '++' operator, interpret it differently.
For furthur information, try searching the Net for "i=i++".
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
The postfix operator returns the value before the operation, if i == 20, i++ returns 20, ++i return 21.
x=y++ + x++;
y= ++y + ++x;
This sort of code is an interesting exercise, but you should never write code that looks like this, in the real world.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello ,
I have written a program in VC++.Net 2003 on a laptop,
when I try to run the setup on a desktop, there is a change in the
forms size, location (appearence settings).
For e.g. On the laptop the form appears to be full screen,
but on a desktop the form is smaller.
How do I make sure , that the settings are the same independent of
the machine.
Thanks in advance for your help.
Minad
|
|
|
|
|
Users control the screen resolution as part of their "Display settings". Your form is the same "pixel size" on both machines.
led mike
|
|
|
|
|
hi all,
anybody tell me where i can find readymade library for maintaing log?
payable or not doesn't matter.
please,if anybody idea share with me.
thanks & regards
bankey khandelwal
|
|
|
|
|
|
Hi guys,
I was just wondering if it is possible to assign a value class direct to a unmanaged structure without
assigning individual variables and vice versa?
/krissi
|
|
|
|
|
kristmun wrote: if it is possible to assign a value class direct to a unmanaged structure without
assigning individual variables and vice versa?
Yes System.Runtime.Interop.Marshal class has those methods.
led mike
|
|
|
|
|
Ok, on previous posts you may have noticed that I have been playing around with processes and the like.
I have created a Console application that fires up NOTEPAD and access the menus but I need to ensure that it remains as the ForegroundWindow .
To do this I need to acquire the Handle of the process that I started then apply it to the ForegroundWindow property - this is where I am having trouble.
The following is how I start NOTEPAD then return it's MainWindowHandle which is a IntPtr :
<br />
IntPtr Hnd;<br />
<br />
Process^ Proc = gcnew Process;<br />
Proc->StartInfo->FileName = "NOTEPAD.EXE";<br />
Proc->Start();<br />
Proc->WaitForInputIdle();<br />
Hnd = Proc->MainWindowHandle;<br />
Now when I include the following line:
SetForegroundWindow(Hnd);
I get the following error when compiling:
<br />
error C2664: 'SetForegroundWindow' : cannot convert parameter 1 from 'System::IntPtr' to 'HWND'
Can I conver a IntPtr to a HWND ?
Pete
|
|
|
|
|
G'Day Pete
Give this a go
::SetForegroundWindow((HWND)(Hnd.ToPointer()));
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
G'Day Josh,
Yep.... look'n good.
Thanks again and have a great Xmas.
Pete
|
|
|
|
|
I am using Managed C++ (VS .NET 2003 SP1), so I can't use any of the new features in C++/CLI (VS 2005).
I have a function that needs to take in a const reference to a native class, e.g.,
void MyManagedClass::f(const UnmanagedClass& u); If I just call it straight, like (inside another member function of MyManagedClass ):
UnmanagedClass u;
f(u); then it works OK. However, I would like to call this function in another thread. I have something like this, but it doesn't work:
__delegate System::Void ThreadDelegate(const UnmanagedClass&);
UnmanagedClass u;
ThreadDelegate* td = new ThreadDelegate*(this, f);
Object* args[] = new Object*[1];
args[0] = &u;
Invoke(td, args);
The problem is passing the parameter to the delegate. I would rather not have to write a managed wrapper for my unmanaged class if it can easily be avoided. Is there any way to do what I want? I have tried putting in __nogc in various parts of the array declaration but I can't get it to compile.
--
Marcus Kwok
|
|
|
|