|
use vector::at.
Ex. myNexCObject = VectorObjects.at(0);
|
|
|
|
|
std::vector.at() does validate the vector boundaries.
The operator[] does not. It will happily access outside the vector. No problem when you know that, though.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Hello,
thanks for input!!
regards
termal
|
|
|
|
|
You mentioned seaching also. If this is something you are looking for, then I suggest using the std::map class instead of a vector.
|
|
|
|
|
is there any problem specifying custom index in TlsSetValue other than the index returned by TlsAlloc ??
//
TlsSetValue ( 1 , (LPVOID)MyData ) ;
Tahnks & regards
|
|
|
|
|
nitin3 wrote: ...other than the index returned by TlsAlloc ??
Not according to the docs.
"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
|
|
|
|
|
As long at the index was allocated by using TlsAlloc( ), then there should be no problem.
---
Yours Truly, The One and Only!
devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
Hi All,
In my from I want such type of function which copy directory from one path to other. The function should be as
CopyDir(SourcePath,DestinationPath);
Is there any API provided by MFC for doing the same.
Thanks in Advance
Atul
|
|
|
|
|
There is no direct function to copy directory.
But you can use FindFirstFile/FindNextFile to search files in directory.
Then use CopyFile function to copy files.
|
|
|
|
|
|
Hi
How to change associativity of operators in C++,
e.g.
if we have
int a = 15;
int b = 5;
int c = a---b;
then compiler interpret this expression as
int c = (a--) - b;
what I want, is like int c = a -(--b);
is there any way to achieve this.
Please suggest me.
Thanks & Regards
|
|
|
|
|
Use proper parenthesis in your code.
|
|
|
|
|
I don't think so.
Because the compiler doesn't know your minds. All automatic parsing is defined by rules.
Like mathematics, if you calculate 5+5*6 you should begin with 5*6 and then + 5
if you specifie it (5+5)*6 you start with adding 5+5 then the *6
It's the same in programmation.
|
|
|
|
|
Hi
thanks for your replies
Is there any prgma option to do this
please suggest me
Thans & regards
|
|
|
|
|
rajeevktripathi wrote: Is there any prgma option to do this
I didn't found any.
|
|
|
|
|
NishantB++ wrote: I didn't found any.
of course you didn't, 'cause there aren't any !
this feature is a fundamental of the language itself !!!
|
|
|
|
|
rajeevktripathi wrote: Is there any prgma option to do this
No. There is no need for that.
You write the parenthesis in your code where you need them.
When in doubt, add a pair of parenthesis. Extra pairs of parenthesis won't do any harm.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
jhwurmbach wrote: Extra pairs of parenthesis won't do any harm
no need. one pair is largely sufficient, because it can be countered with simple spaces...
|
|
|
|
|
rajeevktripathi wrote: How to change associativity of operators in C++,
changing associativity is like changing the meaning of things (so, changing the language itself), so, no way at all.
moreover, if associativity exists like it is, there are reasons over the problem you can have with it.
rajeevktripathi wrote: then compiler interpret this expression as
int c = (a--) - b;
what I want, is like int c = a -(--b);
then, why don't you just use spaces (or at least, parenthises like someone said) ?
write c = a - --b; and everything will be good.
|
|
|
|
|
rajeevktripathi wrote: is there any way to achieve this.
Why make things harder than necessary:
int a = 15;
int b = 5;
a--;
--b;
int c = a-b;
"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
|
|
|
|
|
Suppose I have two classes:
class A{
public:
A();
virtual ~A();
};
class B : virtual public A{
public:
B();
~B();
};
and I now do:
A * pA = new B();
dynamic_cast <B *> (pA);
Is there any problem. My question is actually: does the virtual inheritance affect the dynamic_cast
Thanks in advance.
Toe the line
Thread the needle
Think outside of the box
|
|
|
|
|
there's no pb AFAIK. polymorphism is fully known by the compiler, and the dynamic_cast should do the job.
|
|
|
|
|
Thanks for clarifying it for me. I did test it in Visual Studio and found not problem either
Toe the line
Thread the needle
Think outside of the box
|
|
|
|
|
I want to use DirectShow's interface IMediaDet to retrieve codec info from media files.
I only want to check the audio codec is AAC and video codec is MPEG-4.
How to resolve such task?
Thanks.
GOOD LUCK
|
|
|
|
|
Does the step-by-step info in the DirectShow SDK help?
IMediaDet Interface[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|