This very simple code gives me tons of errors:
#include <iostream>
#include <string>
int main() {
std::string test = " ";
std::cout << test;
}
I tried to compile it on linux by typing gcc -o simpletest simpletest.cpp on the console. I can't see why it isn't working. What is happening?
...
Google guys seems to know their game and I like learning from those smarter than me. Google is sharing a lot of code with open source community. Their docs and APIs are IMO state of the art. Which tools / APIs would you recommend for a C++ developer? I'm interested both in looking at interesting solutions / tricks as well as using some G...
I hope someone can help me with this, I'm mostly a C# developer so my
C and C++ skills are bad. I have a native C dll that is a plugin of a
larger application. I cross compile this dll for windows on linux
using gcc.
In the native dll when I create a D3DSurface I want to call a function
in a Mixed Mode C++ dll and pass in the pointer ...
I'm trying to create a template class to insulate the users from a data type. I would have preferred to use an adapter class, but the function signatures needed to change requiring a template.
In the code sample below(not the actual project just a simplified version to illustrate the problem), while in the main routine I'm able to use ...
In C++ when can a virtual function use static binding? If it is being accessed through a pointer, accessed directly, or never?
...
I have some code that looks like:
template<unsigned int A, unsigned int B>
int foo() {
int v = 1;
const int x = A - B;
if (x > 0) {
v = v << x;
}
bar(v);
}
gcc will complain about x being negative for certain instantiations of A, B; however, I do perform a check to make sure it is non-negative. What's the best way arou...
So, I've been doing Java for a number of years now, but now I'm starting a C++ project. I'm trying to determine best practices for setting up said project.
Within the project, how do you generally structure their code? Do you do it java style with namespace folders and break up your source that way? Do you keep your public headers in an...
For example:
Base class header file has:
enum FOO
{
FOO_A,
FOO_B,
FOO_C,
FOO_USERSTART
};
Then the derived class has:
enum FOO
{
FOO_USERA=FOO_USERSTART
FOO_USERB,
FOO_USERC
};
Just to be clear on my usage it is for having an event handler where the base class has events and then derived classes can add events. The derived classes...
Is there an elegant way to specialize a template based on one of its template parameters?
Ie.
template<int N> struct Junk {
static int foo() {
// stuff
return Junk<N - 1>::foo();
}
};
// compile error: template argument '(size * 5)' involves template parameter(s)
template<int N> struct Junk<N*5> {
static in...
I have a file with data listed as follows:
0, 2, 10
10, 8, 10
10, 10, 10
10, 16, 10
15, 10, 16
17, 10, 16
I want to be able to input the file and split it into three arrays, in the process trimming all excess spaces and converting each element to integers.
For some reason I can't find...
I'm looking for a wrapper that distills zlib to:
OpenZipFile()
GetItemInfo(n)
UnzipItem(n) // Bonus points for unzipping recursively if item n is a directory.
I see a lot of wrappers around the zlib library on, say, codeproject.com but they are all platform-specific in order to provide the added platform-specific functionality of un...
FILE * __cdecl _getstream
I'm calling an fopen and it keeps crashing.
AfxMessageBox("getting here 1");
FILE * filePtr = fopen(fileName, ("rb") );
AfxMessageBox("getting here 2");
For some reason I never get to the second messagebox.
What makes it more interesting is that in debug mode the app works perfectly.. Most frustrating..
...
I know that you can use a dummy "int" parameter on operator++ and operator-- to override the postfix versions of those operators, but I vaguely recall something about a dummy parameter that you could declare on a destructor. Does anyone know anything about that, and if so, what that dummy parameter did?
This was in my old Turbo C++ tuto...
Are there any good source-code analyses tools for OSX. I am particularly interested in tools that are capable of diagramming function-call hierarchies for C and C++ source files.
...
I've met a really strange problem:
The code is as follow:
::boost::shared_ptr<CQImageFileInfo> pInfo=CQUserViewDataManager::GetInstance()->GetImageFileInfo(nIndex);
Image* pImage=pInfo->m_pThumbnail;
if(pImage==NULL)
pImage=m_pStretchedDefaultThumbImage;
else
{
//
int sourceWidth = pInfo->GetWidth();
int sourceHeight = pInfo->GetH...
So I've been trying to learn the boost::asio stuff to communicate to a serial device using RS232. The documementation is sparse and the examples are non-existent. Can't figure out exactly how to communicate with the device. The device can't send data so all I need to do is write, but other projects require actual back and forth commun...
When we perform a fork in Unix, open file handles are inherited, and if we don't need to use them we should close them. However, when we use libraries, file handles may be opened for which we do not have access to the handle. How do we check for these open file handles?
...
I have written a Windows service that allows me to remotely run and stop applications. These applications are run using CreateProcess, and this works for me because most of them only perform backend processing. Recently, I need to run applications that present GUI to the current log in user. How do I code in C++ to allow my service to lo...
I think most C++ programmers here would agree that polluting the global namespace is a bad idea, but are there times when this rule can be ignored?
For example, I have a type that I need to use all over a particular application - should I define it thus:
mytypes.h
typedef int MY_TYPE;
foo.cpp
MY_TYPE myType;
Or use a namespace:
m...
I have a QGraphicsScene that I want to copy and append to the start of a list. What is the best method of doing this?
QGraphicsScene* m_scene = new QGraphicsScene();
QGraphicsScene* m_DuplicateScene;
QList<QGraphicsScene *>m_list;
...