|
Hi, I'm beginner. I tried run project (http://opensteer.sourceforge.net/[^]). There is a main program and a few ready plugins. I compiled and run *.exe, but when I was switching plugins, traying run the last one (The most and only one important to me) "soccer" I had a message box:
------------
Microsoft Visual C++ Debug Library
Debug Assertion Failed!
Program: E:\opensteer\win32\bin\OpenSterDemo_d.exe
File: c:\progeam files\microsoft visual studio 8\vc\include\vector
Line: 1463
Expression: vector<bool> iterator not dereferencable
For information on how your program can cause an asseration
failure, see the Visual C++ documentation on asserts.
-------------
Could anybody help me ? please....
regards, Daniel.
PS: If something, maybe My english, is not understable I can try write in other way.
thx
|
|
|
|
|
This is not exactly a programming question. You should ask for help in the stree forum[^].
-Saurabh
|
|
|
|
|
I know that OpenSterr has own forum, but here are more people and... very smart
If, however, somebody could tell me something important, i'll be grateful.
Btw. after this msg. when I click IGNORE, I've last msg.:
//after choose IGNORE in msg box, next:
Microsoft Visual C++ Debug Library
Debug Assertion Failed!
Program: E:\opensteer\win32\bin\OpenSterDemo_d.exe
File: c:\progeam files\microsoft visual studio 8\vc\include\vector
Line: 1463
Expression: ("Standard C++ Libraries Out of Range", 0)
For information on how your program can cause an asseration
failure, see the Visual C++ documentation on asserts.
Thx anyway, BR.
Daniel.
|
|
|
|
|
What I need is very simple, copy some file to a directory where the application is.
|
|
|
|
|
|
Do you need to SHFileOperation?
|
|
|
|
|
I have a class that wraps a std::map (never mind why). To make it seamless to use I re-implement a number of the functions found on std::map, like find(), begin(), erase(), insert(), etc, and then just call the underlying map collection.
So I am working on porting this code to the Mac (which means I'm going to be pissing and moaning the rest of the day) and came across this gem:
error: conversion from 'void' to non-scalar type 'std::_Rb_tree_iterator<std::pair><const std::string,="" int=""> >' requested
</const></std::pair>
After digging and silently swearing under my breath I find that the GCC implementation of std::map::erase is different than what you find on Microsoft (note that the code worked on ALL versions of MS C++ from VC6 to VC9). Microsoft's is like this:
iterator erase( iterator i );
GCC's
void erase( iterator i );
So who's right?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Generally when I have doubts about STL I check SGL STL[^].
In this case MSDN clearly says that return type of map does not conform to the C++ standard link[^].
-Saurabh
|
|
|
|
|
Grrrr why would they (MS) do that? I can see the mistakes in the VC6 version, but why keep promoting it through the other versions of the compiler???
Anyhow thanks for the info!
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Don't know my MS decided to do it this way but once C++0x is officially released MS implementation will be correct and other STL vendors will have to make the correction. In C++0x all containers erase functions should return iterator one past erased iterator n2350[^].
-Saurabh
|
|
|
|
|
because they value functionality and backwar compatibility over standard compliance?
It supposedly makes it more obvious to selectively erase items from a list while iterating through it:
for(it=cont.begin(); it!=cont.end();)
{
if (ToUglyToKiss(*it))
it = cont.erase(it);
else
++it;
}
otherwise:
for(it=cont.begin(); it!=cont.end();)
{
iterator cur = it;
++it;
if (ToUglyToKiss(*cur))
cont.erase(cur);
}
well, not to bad either, but I see how it can make a difference in more complex code.
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist
|
|
|
|
|
hi all
is there any help to say , what is the best Book Or Reference for Visual c++ .
I'm new in visual c++
thanx very lot
s_mostafa_h
|
|
|
|
|
If one book could take you from beginner to intermediate programmer, (in Visual C++) it would have to be Ivor Horton's "Beginning Visual C++ 6" or there are versions for VC++ 2005 and VC++ 2008.
They are all basically the same except the newer ones add some odd chapters on WinForms and a small dose of .NET for completeness.
First half of the book teaches C++, the second half is about Windows programming. MFC is the dominant class library used.
|
|
|
|
|
I don't think that there is single book which is the final reference of entire VC++ programming stuffs. From my experience, I recommend 4 books, by which you can pass most of the hurdles that a typical windows programmer will encounter.
1) If you are a beginner and want to learn the basics of windows programming then,
- Programming Windows by Charles Petzold - Its a classic.
2) If you want the reference for MFC, then
- Programming MFC by Jeff Prosise.
3) If you want to do some kernel stuff, then.
- Programming Applications for Microsoft Windows by Jeffrey Richter.
4) If you want a reference for debugging, then
- Debugging Applications by John Robbins.
Regards,
Jijo.
________________________________
http://weseetips.com - Daily Visual C++ technical tips.
|
|
|
|
|
thanx ,
now i want to know is there any differ between Visual C++ 6 & VC++ 2005 or ... other version actually.
sometimes this very important to know this .
rgds
s_mostafa_h
|
|
|
|
|
Indeed. They differs a lot.
1) Visual Studio 2005 stays more close to C++ language specifications. Where in VC 6.0 you might miss some language features. For instance try-catch block in body of constructor. I couldn't compile it in my VC 6.0 SP5.
2) But don't under-estimate VC 6.0. I've to admit that VC 6.0 is one of the best IDE that ever build. You see, still its being used by lot of companies for lot of products. Its still popular now.
3) In VC++ 2005 supports .net platform where VC++ 6.0 don't.
Have a look at Wiki[^] about the different versions of Visual C++.
Regards,
Jijo.
________________________________
http://weseetips.com - Visual C++ technical tips.
|
|
|
|
|
And see www.cplusplus.com.
|
|
|
|
|
I'm getting the feeling that when using strtol and I'm interested in the global errno value before and after the call to strtol, I need to reset the global errno to zero (or some nothing value) in order to detect an error.
The documentation only says to check it before and after but if it was already set to ERANGE before the call and it overflows, it will still be ERANGE afterward.
Is it standard practice to reset errno explicitly before using strtol?
|
|
|
|
|
Unless LONG_MAX and LONG_MIN are valid input values, you can check return value first then check errno without being busy with errno before the function call.
<br />
long lVal = strtol(pszNum, &pEndPtr, 10);<br />
if((LONG_MAX == lVal) || (LONG_MIN == lVal))<br />
{<br />
}<br />
Your concern is valid when input value equals either LONG_MAX or LONG_MIN. Because, it returns LONG_MAX or LONG_MIN (defined limits.h) if an overflow (or underflow) condition occurs.
modified on Saturday, April 26, 2008 6:14 PM
|
|
|
|
|
Ozer Karaagac wrote: Unless LONG_MAX and LONG_MIN are valid input values
They are valid inputs and will not cause an error.
Ozer Karaagac wrote: Your concern is valid when input value equals either LONG_MAX or LONG_MIN.
Any string that equates to an integral value larger than these as well.
I guess I'm still unsure whether I can just reset errno before the call to strtol or am I required to read it, reset it, call strtol, check error, restore errno to it's original value?
|
|
|
|
|
I will try to help your decision.
For larger decimal values, you may consider to use different functions like _atoi64() or strtod() to widen the limits.
When it comes to errno, it is an immediate value. You don't have to save/restore errno unless you are going to use it afterwards. I think, this is not a good practice also. If you plan to use that value later, you should save it in another variable. Thus, resetting it before the function call is enough to see whether LONG_MAX is real result or the error flag.
Runtime library functions change this variable only when an error occurs and report the situation by returning an error value. It's also beneficial to inspect runtime library source codes that may come with your compiler (in MSVCDIR\CRT\SRC for MSVC).
I did inspect the strtol() source code just now. And it only assigns ERANGE value to errno in one line. So, any value other than ERANGE will not be related to strtol() also. But,
if((LOMG_MAX == lVal) || (LONG_MIN == lVal))
{
if(ERANGE == errno)
else
}
modified on Sunday, April 27, 2008 11:15 AM
|
|
|
|
|
Thanks for the guidance.
I think I have something upwards of 100+ books on C/C++, MFC, Windows, etc...
not to mention MSDN and none of them are very explicit about resetting errno before the call to strtol.
Granted, what they do say about it and what intuition tells me is getting pretty clear. Your comments have helped.
|
|
|
|
|
Hi All,
Having romped in the Elysian field that is C# I'm now being forced to learn C++. To this end I've managed to crawl through this book to Chapter 8 but I'm having trouble with 8-3 - using iterators instead of passing a vector.
Briefly, how is the template supposed to operate on the vector if the vector isn't passed in one form or another??
I have, without doubt, got the wrong end of the stick here...
I'm not looking to be spoon fed the answer (I don't expect anything in C++ to be easy), but an indication of how to proceed would be of immense help.
Thanks
Si
|
|
|
|
|
I think you are making a wrong assumption that people here have read the C++ book you are reading. Always ask complete question rather than pointing to the book.
If I understand question completely that you are asking how a function which is passed an iterator will operate on vector. Well the iterators point to the vector! Think of iterators as pointers so when you pass an iterator to the vector you are passing a pointer to the vector. Now iterator is not exactly a pointer but it follows pointer semantics i.e. you can deference it *it, increment it ++it, decrement it --it, etc.
If you want to read more about STL then try SGI STL[^] and it has good introduction to iterators[^].
-Saurabh
|
|
|
|
|
Hi Saurabh & thanks for replying. Actually, the assumption I was making,probably wrongly, was that only people familiar with the book would reply but perhaps I should have made that more clear; in any case apologies.
To make the question more general - we have a template function that takes a vector as an argument:
template <class T>
T median(vector<T> v)
{...}
The task is this: instead of passing the vector ('v')by value, rewrite the function to operate on iterators.
This is probably v. trivial but has me stumped.
Here's the code I have so far if anyone's interested
#include "stdafx.h"
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
T median(vector<T> v)
{
typedef typename vector<t>::size_type vec_sz;
vec_sz size = v.size();
if (size == 0)
throw domain_error("median of an empty vector");
sort(v.begin(), v.end());
vec_sz mid = size/2;
return size % 2 == 0 ? (v[mid] + v[mid-1]) / 2 : v[mid];
}
int main()
{
vector <float> v1;
vector <int> v2;
for (int i=0; i < 10; i++)
{
v1.push_back(i+5);
v2.push_back(i+5);
}
int size = median(v1);
double sf = median(v1);
cout << "The median of the float vector v1 is " << median(v1) << endl;
cout << "The median of the int vector v2 is " << median(v2)<< endl;
system ("pause");
return 0;
}
I think what I'm asking is that if the vector isn't present in the template function, how can iterators like begin() & end() possibly work on it?
Also, why does C++ have to be so awkward and obscure and frustrating (actually no reply needed to that - I know you all love it and I don't want to start a row).
Thanks
Si
|
|
|
|