I wrote some custom c++ code and it works fine in ubuntu, but when I upload it to my server (which uses centos 5) its fails and says library is out of date. I googled all around and centos cannot use the latest libraries. How can I compile against the stl so that it is included in the binary and it doesn't matter that centos uses an ol...
I am in the preparation phase of the design a graph-based (or key-value) database library for C++ which many here will find similar to projects such as http://neo4j.org/.
Since this is a very early phase of design, my requirements are simple, unrefined and (I admit) probably still rather naive:
A directed acyclic graph
A tree-like st...
I have a win32/MFC application with a context menu that I build programatically:
CPoint pt;
GetMenuPopupPos(&pt);
CAtlString csItem = _T("&Example");
CMenu menu;
menu.CreatePoupMenu();
menu.AppendMenu(MF_STRING, IDM_EXAMPLE_COMMAND, csItem);
menu.TrackPopupMenuEx(TPM_LEFTALIGN|TPM_LEFTBUTTON, pt.x, pt.y, this, NULL);
I've omitted the ...
I have a scene drawn in openGL (openGl 1.1 win32).
I use glClipPlane to hide foreground objects to allow the user to see/edit distance parts. The selection is done natively without using openGL.
But the glClipPlane applies to all openGL elements - coordinate icons, gridlines etc and even elements drawn in gluOrtho2D on top - scale bars...
In C specifically (i suppose this also applies to C++), what is the difference between
char str[4] = "abc";
char *cstr = {"abc"};
Problems arise when i try and pass my "abc" into a function that accepts char**
void f(char** s)
{
fprintf(stderr, "%s", *s);
}
Doing the following yields a compiler error. If cast to char** (to make c...
Hi,
Some overflow runtime error happens when my C++ program is trying to write some .png images into a directory.
The directory where the images are written into is given as a command line argument. The program is compiled with gcc -ggdb3 -O3. It is strange that the error disappears if I change the directory to another one when rerun...
For the example under Friend Functions
How is the following true?
"Notice that neither in the declaration of duplicate() nor in its later use in main() have we considered duplicate a member of class CRectangle. It isn't! It simply has access to its private and protected members without being a member."
Duplicate is declared in the publ...
I'm learning C++ for one of my CS classes, and for our first project I need to parse some URL's using c-strings (i.e. I can't use the C++ String class). The only way I can think of approaching this is just iterating through (since it's a char[]) and using some switch statements. From someone who is more experienced in C++ - is there a be...
I've been having a discussion with my coworkers as to whether to prefix overridden methods with the virtual keyword, or only at the originating base class.
I tend to prefix all virtual methods (that is, methods involving a vtable lookup) with the virtual keyword. My rationale is threefold:
Given that C++ lacks an override
keyword, the...
I am trying to create a graphics library...
i need to
int NewDisplay(Display **display, DisplayClass dispClass, int xRes, int yRes)
{
/* create a display:
-- allocate memory for indicated class and resolution
-- pass back pointer to Display object in display
*/
return SUCCESS;
}
How can i allocate memory to class and to t...
For a C++ console application compiled with Visual Studio 2008 on English Windows (XP,Vista or 7). Is it possible to print out to the console and correctly display UTF-8 encoded Japanese using cout or wcout?
...
I am reading Nicolai Josuttis book on C++STL algorithms. For many algorithms such as stable_sort(), he mentions that the complexity of the algorithm n * log(n) if enough memory is available, otherwise it is n * log(n) * log(n). My question is how does the memory usage affects the complexity ? And how does STL detect such a situation?
...
I have a project that is built with native C++, as well as C++/CLI. I have the following components:
Assembly A (C++/CLI)
| uses
Assembly B (C++/CLI)
| uses
Static Lib C (Native C++)
I did a major re-write of Static Lib C, and it compiles, and other native projects that use it compile fine as well. None of Assembly B changed in t...
I try to set an attribute in a XML node using MSXML. IXMLDOMElement alone has the member function setatrribute. So i got the document element.
pXMLDocumentElement -> get_documentElement (& pElement );
pElement -> selectSingleNode ( nodePathString ,& pNode );
.
.
.
pElement -> setAttribute ( bstr , var );
I selected the required node i...
can anyone tell me whats the difference between
Display *disp = new Display();
and
Display *disp;
disp = new Display();
and
Display* disp = new Display();
and
Display* disp(new Display());
Regards,
Zeeshan
Also, i am very new to c++, just trying to figure out a few things.
If you thing my questions are smelly, let me kno...
Hi,
I wonder how to specify CDialogBar default size when it is created in MainFrame of a MFC/MDI project. Here is the code to crate dialog bar.
// add Dialog bar window
if (m_wndDlgBar.Create(this, IDD_ADDLGBAR,
CBRS_RIGHT|CBRS_SIZE_DYNAMIC|CBRS_FLYBY, IDD_ADDLGBAR))
{
TRACE0("Failed to create DlgBar\n");
return -1; // fail...
How can we access variables of a structure? I have a struct:
typedef struct {
unsigned short a;
unsigned shout b;
} Display;
and in my other class I have a method:
int NewMethod(Display **display)
{
Display *disp=new Display();
*display = disp;
disp->a=11;
}
What does **display mean? To access variables of struct I h...
I know this is quite a ridiculous question but this is quite confusing and irritating, as something that should work simply is not. I'm using Code Blocks with the GCC compiler and I am trying to simply create a string variable in my class
#ifndef ALIEN_LANGUAGE
#define ALIEN_LANGUAGE
#include <string>
class Language
{
public:
...
I'm trying to produce random integers (uniformly distributed).
I found this snippet on an other forum but it works in a very weird way..
srand(time(NULL));
AB=rand() % 10+1;
Using this method I get values in a cycle so the value increases with every call until it goes down again. I guess this has something to do with using the ti...
I am writing a routine to compare two files using memory-mapped file. In case files are too big to be mapped at one go. I split the files and map them part by part. For example, to map a 1049MB file, I split it into 512MB + 512MB + 25MB.
Every thing works fine except one thing: it always take much, much longer to compare the remainder (...