|
Is my solution correct?
Using *magiitr = &Player1.Magi[mage1]; instead.
How would I be able to standardize my code for this as well? I don't quite understand what you mean by standardize. C++ is C++ as far as I know, and only the complier you use would make any change to that.
Also, could you explain the difference between an iterator and a pointer in this case so I don't screw this kind of thing up again?
|
|
|
|
|
Christian Graus wrote: Assuming an iterator is a pointer, is allowed in VC6, but that is wrong. VC2002 was the first to fix this problem
I'm being a bit pedantic here, but it was always wrong to assume an iterator was a pointer. The fact that it worked on MSVC6 (or any past or future compiler) is just an impementation detail.
Steve
|
|
|
|
|
If an iterator is not a pointer, then what is it?
An instantiation of the template type stored as private member data in the vector class and set equivalent to any arbitrary instance stored in that vector?
|
|
|
|
|
An interator is a "pointer like" object. It can be a pointer or a class or struct . For example, how could a pointer possibly be used as an iterator for a linked list collection such as std::list or a binary tree such as std::set ?
Steve
|
|
|
|
|
I think I understand.
Did my supposed solution seem capable or am I still not understanding things clearly?
Might someone be able to give me an example of how I should write the assignment for magiitr?
Thank you.
|
|
|
|
|
I can't see any of the "<" or ">" characters on what's between in your code.
Steve
|
|
|
|
|
Kataric wrote: If an iterator is not a pointer, then what is it?
It is a generalization of a pointer that allows you to work with different data structures in a uniform manner.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I think the vector operator[] returns a reference to the element at that index, not an iterator.
So you'd want:
player::Magi& magi = Player1.Magi[mage1];
or
player::Magi* pMagi = &Player1.Magi[mage1];
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I must seriously be confused here.
Like Mr. Echols is saying, I could declare a new instance of the player::Magi class and set Player1.Magi[mage1] equivalent.
However, I won't be able have any ->next functionality that comes with the vector iterator, and that's really what I'm after.
I'll also go back and look up references on the vector class.
I shall post more stuff in detail tomorrow in hopes that you can help me figure this out.
|
|
|
|
|
Hey Gentlemen, I contemplated opening a new thread for this question, but hopefully this one will do.
I think I understand what is going on with the darn pointers and interators and how I used them. Unfortunately I'll need to rewrite a lot of things.
However, I'm having another problem with another compiler error.
c:\nehe\magi\magination\spelllist.cpp(1275) : error C2228: left of '.current_energy' must have class/struct/union
The code is question is
caster.Creatures[i].current_energy = nrg[i];
I'm not sure what this "must have class/struct/union means.
Any help would be much appreciated.
|
|
|
|
|
This is typically the cause of that error (at least for me):
CMyObject* pObj = new CMyObject();
pObj.DoSomething();
Try changing it to:
caster.Creatures[i]->current_energy = nrg[i];
and see if that works.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Is there any fuction that compare 2 strs
str1 = "BMW"
str2 = "BmW"
and that fuction would return TRUE (or something else) while comparing these 2 strs?
or should i create that fuction ?
|
|
|
|
|
What are str1 and str2 ? char arrays ? std::strings ? CStrings ? bstr_t ?
Most string classes offer operator ==. Two char * can be compared with strcmp, from memory.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
I just want to return me true below :
CString str = "BMW";
CString str2 = "BmW";
CString str3 = "bMW";
if ( str == str2 && str2 ==str3) etc
|
|
|
|
|
use CompareNoCase function of CString..
|
|
|
|
|
Well i am facking idiot :/ it was inside my eyes and i did a whole post :/
|
|
|
|
|
hm i found MakeUpper for CStrings
so i will make them MakeUpper before i put them in if ( ) {}
right?
|
|
|
|
|
if (0 == str1.CompareNoCase(str2))
{
//strings are equal, ignoring case
}
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
thx about that too (i will use this and not that i said about MakeUpper)
|
|
|
|
|
The old-skool strxxx functions have versions that ignore case - e.g. stricmp()
The i is for ignore!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi all. Im trying to find a reasonable explanation on how to call the ExitThread() function properly. Would i need to call it for every thread i call?
ie:
<br />
<br />
CreateThread(somethread);<br />
CreateThread(somethread);<br />
WaitForMultipleObjects(somethread);<br />
<br />
ExitThread(somethread);
Thanx in advance!
|
|
|
|
|
dellthinker wrote: Would i need to call it for every thread i call?
No. your thread will automatically end when you return from the thread function.
|
|
|
|
|
ExitThread exits the current thread, not some arbitrary thread identified by a HANDLE . The argument is an exit code not a HANDLE .
Steve
|
|
|
|
|
Hello everybody,
lets say i have small 640bytes executable with a code like this:
#include "windows.h"<br />
<br />
int WinMainCRTStartup()<br />
{<br />
MessageBox(0,"AAA","BBB",0<br />
return 0;<br />
}
.rdata and .text sections are merged so there is only one .text section in that *.exe
so what i need to do to add new section manualy, with hexeditor?
i know that i have to add new Image Section header which is 28 bytes lenght and new section at the end of file which is random lenght described in its section header.
I also have to correct each section pointer(in my case just one section) so if i add additional 28 bytes in front of sections i have to add 28byte to each section pointer so in my case offset will be 200+28, but my hexeditor shows that ofset to the section begining is 208, so i will better trust my hexeditor. And finaly i changed sections count to 2 so.. chages were made executable saved but it doesn't work.
what i have missed?
thank you for help in advance
|
|
|
|