I am confused.
I do this:
#include <vector>
// List iteration
typedef vector<registeredObject>::iterator iterator;
typedef vector<registeredObject>::const_iterator const_iterator;
vector<registeredObject>::iterator begin(void);
vector<registeredObject>::const_iterator begin(void) const;
vector<registeredObject>::iterator end(void);
ve...
I have some extern'd variables in a namespace in a header file, and I'm trying to initialize them in its corresponding cpp file. However, I keep getting the error given in the topic title. I'm not sure what the problem is.
EX:
// Some header
namespace foo
{
extern SDL_Surface* bar;
}
// In the impl file
#include "someheader.h"
foo...
This is an excerpt of some c++ code, that i'll have to explain in detail in some days:
std::vector<int> vct(8, 5);
std::generate(vct.begin(), vct.end(), &rand);
std::copy(vct.rbegin(), vct.rend(),
std::ostream_iterator<int>(std::cout, "\n"));
i think i understand everything about it, except that tiny mystical &rand. what exactly...
if you know there is one, can you let me know what its for ? if not please say so : ) thanks.
Signature : void * malloc(unsigned long size, struct malloc_type type, int flags);
for example. other flags are...
M_ZERO
Causes the allocated memory to be set to all zeros.
M_WAITOK
Indicates that it is OK to wait for...
I'm trying to write a paint program (paint where ever a mouse press/hold is detected), but I'm having trouble using the Qt QPainter. I have read the documentation on their web site and I'm still kind of lost. A link to a tutorial that isn't on their web site would be nice or maybe explain to me how I can accomplish this in Qt. The only t...
Someone please see my code at this link for input taken from this file( 2.2 mb file). This produces seg fault. By gdb, it shows seg fault in _vfprintf_r(). But when I comment line 41 and uncomment 38 (a null statement), there is no segmentation fault. line no 41 is just print statement. Someone please help. I am frustated and wasted a da...
Given the following scenario, which one of the following is preferred.
m_state is a member rater than a local variable.
class C
{
private:
double m_state;
public:
double state() const { return m_state; } // returns double
double& state() { return m_state; }
}
===========================================
class C
{
private:
...
I got this weird error when I was trying to compile matlab to C++ using the following command:
'mcc -W lib:cshared -d ' clibdir ' -T link:lib ' mfile
The error I got was:
fatal error C1083: Cannot open include
file: 'windows.h': No such file or
directory
Now, I was using lcc as my compiler ( instead of the Visual Studio one)...
What's a good way to download HTTP URLs (e.g. such as http://0.0.0.0/foo.htm ) in C++ on Linux ? I strongly prefer something asynchronous. My program will have an event loop that repeatedly initiates multiple (very small) downloads and acts on them when they finish (either by polling or being notified somehow). I would rather not have...
Does SHFileOperation support to move and rename files at the same time?
I'v got a set of files :
c:\
f1.bmp f2.bmp f3.bmp f4.bmp
I want to move each to new folder, and rename them:
d:\
b1.bmp b2.bmp b3.bmp b4.bmp
Can I use SHFileOperation? and just do it once?
Many thanks!
...
I'm implementing a Knuth shuffle for a C++ project I'm working on. I'm trying to get the most unbiased results from my shuffle (and I'm not an expert on (pseudo)random number generation). I just want to make sure this is the most unbiased shuffle implementation.
draw_t is a byte type (typedef'd to unsigned char). items is the count of i...
im storing some settings for objects in an array. the id's of objects are used as the key. the id's start from 100000 and go up. if i was to input data for an object with id 100 000, would cpp automatical create 99999 blank key entries starting from 0?
...
#include<iostream>
using namespace std;
struct sample
{
int data[3][2];
};
struct sample* function()
{
struct sample s;
int c=1;
for(int i=0;i<3;i++)
for(int j=0;j<2;j++)
s.data[i][j]=c++;
cout<<"Matrix contents are ";
for(int i=0;i<3;i++)
{
for(int j=0;j<2;j++)
cout<<s.data[i][j])<<"\t"...
Is there a way to convert a vector to a pointer to a pointer (ptr-to-ptr).
Background:
I have an arbitrary length set of data stored in a vector. But I have a library of algorithms that accept ptr-to-ptr (for image array access). I need to get the data from my vector to a ptr-to-ptr. How is that possible?
...
So let's say I do something like this:
QIcon myIcon(":/resources/icon.ico");
How can I later determine the path for that icon, e.g.
QString path = myIcon.getPath();
The problem is, there is no getPath() member. And I can't find anything similar, but surely there must be a way! :(
I guess I could inherit the QIcon class and add thi...
I have a _bstr_t variable bstrErr and I am having a CString variable csError. How do I set the value which come in bstrErr to csError?
...
I have to store lot of strings in c++ map to keep unique strings and when ever duplicate string occurs I just need to increment the counter (pair.second). I've used c++ map and it well fits to this situation. Since the file that processing is gone now upto 30gig I am trying to keep this in a file instead of memory.
I also came across ...
I'm having a problem sorting my derived classes with the STL sort function.
Example -
The header:
vector<AbstractBaseClass *> *myVector;
In the ImpL:
sort(myVector->begin(), myVector->end(), compareBy);
The comparator:
bool MyClass::compareBy(AbstractBaseClass& a, AbstractBaseClass& b) {
return (a->someMethod() < b->someMeth...
When I build my project it compiles well, but when Linking it throws huge number of LNK errors! error LNK2001, error LNK2005, error LNK2019 were there in the error list
>Linking...
1>MultiCatAttributeInfo.obj : error LNK2019: unresolved external symbol "public: class std::vector<class std::basic_string<char,struct std::char_traits<char>...
I have to create a log file for all internet connection made by PC. It should have details of the username, time of connection, etc. I do know about the InternetGetConnectedState() function which returns the bool value. Know how do I get the other details. Can some one help me out thanks in advance. I am using win32 API and visual c++.
...