c++

Adding new line to button's title/description in outlook 2007 ribbon

Hi I am developing an add-in for Outlook ribbon 2007 using ATL/C++. The ribbon tab contains a dynamic menu which has a list of buttons generated at run-time. I would like to add new line to the button's label and/or description but not sure how. I tried adding newline character ("\n") to the button's label and description but it looks l...

How to add a 'new' class to a vector

I am writing a server in C++ and created a class called client to store information about connected clients. I wanted to store the clients in a vector. I have a call "clients.push_back(new client(addr,fd));" to add a client object to the vector clients. I get the following error on compile "server.cpp:67: error: no matching function for...

How can I guarantee type safety in a function that accepts an unlimited amount of arguments?

The FastFormat library works like this: string example; fastformat::fmt(example, "I am asking {0} question on {1}", 1, "stackoverflow"); It also claims "100% type-safety". I can understand how other libraries such as boost::format achieve that by overloading operator%, something I do fairly often with my code too. But if I was able t...

Instantiating an ActiveX Object

I have imported an ActiveX library into my project in Visual Studio 2008 using: #import "TeeChart8.ocx" named_guids Now I would like to create objects exposed by the ActiveX library. However, I am having trouble understanding the API. There are two files that were created after I built the project with the #import, a .tli file and a...

Function call in wrong order

This is what i have coded today #include <iostream> using namespace std; int function1() { cout<<"hello from function1()"; return 0; } int function2() { cout<<"hello from function2()"; return 0; } int main() { int func_diffresult = 0; func_diffresult = function1() - function2(); cout<<func_diffresult; /** prints 0 cor...

eclipse compiling error

I just installed cygwin and eclipse on my win7 x64 machine, and after importing my code from svn, I get this weird error: **** Build of configuration Default for project platform **** make all g++ -O2 -g -Wall -fmessage-length=0 -c -o platform.o platform.cpp process_begin: CreateProcess(C:\cygwin\bin\g++.exe, g++ -O2 -g -Wall -fmess...

Artifically Limit C/C++ Memory Usage

Is there any way to easily limit a C/C++ application to a specified amount of memory (30 mb or so)? Eg: if my application tries to complete load a 50mb file into memory it will die/print a message and quit/etc. Admittedly I can just constantly check the memory usage for the application, but it would be a bit easier if it would just die...

QSharedPointer Invalid Address specified to RtlFreeHeap

I have a program that makes heavy use of QShared Pointer. When I execute my program it runs fine, but when I debug it with GDB it starts throwing errors. "Invalid Address specified to RtlFreeHeap" is thrown in the following code: QSharedPointer<PersistentList> p = PersistentList::createEx(wrap("abc")).dynamicCast<PersistentList>(); QS...

"Unresolved External Symbol" errors when creating object in C++

I'm a pretty seasoned programmer but I'm just now diving into C++ and it's... well... more difficult than PHP and Python. I keep having unresolved external errors when trying to create an object from some classes. It's broken up into multiple headers and files but here is a basic idea from one of my classes: die.h: #ifndef DIE_H #defin...

Is it possible to do a reduction on an array with openmp?

Does OpenMP natively support reduction of a variable that represents an array? This would work something like the following... float* a = (float*) calloc(4*sizeof(float)); omp_set_num_threads(13); #pragma omp parallel reduction(+:a) for(i=0;i<4;i++){ a[i] += 1; // Thread-local copy of a incremented by something interesting } // a ...

Is there a way to have a process created by CreateProcess open within another window?

Hello, I want to be able to open a GUI application using CreateProcess in a main process and have the GUI display in a window I create from within the main process. Does anyone know how to achive this? Thanks! ...

Exponential Operator in C++

I am taking a class in C++ and I noticed there are only a few math operators to use. I also noticed that C++ does not come with an exponential operator within its math library. Why must one always write a function for this? Is there a reason for the makers o C++ to omit this operand? Thanks ...

Why don't people use c++ to make operating systems

Why are Linux, MacOS and other operating systems written in C and not in C++? Isn't C++ C with new features? ...

Assignment of data-member in read-only structure, class in STL set

The minimal example of the problem I'm having is reproduced below: #include <set> using namespace std; class foo { public: int value, x; foo(const int & in_v) { value = in_v; x = 0; } bool operator<(const foo & rhs) const { return value < rhs.value; } }; int main() { foo y(3); set<foo> F; F.insert(y); // No...

deleting object pointer referring by two pointers

I have an object say. ClassA *obj1 = new ClassA; ClassA *ptr1 = obj1; ClassA *ptr2 = obj1; When I do delete ptr1;, will it affect ptr2? If so what can be the correct solution for this? ...

C++ Huffman Tree and Pointers

I am creating a Huffman Tree and to do so I started with making a Min Heap. The heap is set up and works sorting the values by frequency in the document but my problem comes when I try to start creating the tree. I am popping the top two items off the heap and putting a node above them and reinserting into the heap. The heap is array ...

GLib - main event loop in C++

Hello, I need to implement my own main event loop in C++ which will be based on GLib library. I don't know where to begin. I studied some materials about GLib, but it doesn't help me to know, how implement event loop. Could somebody give me some advise about it or give me some source code? I basically need to implement GSource and GSourc...

How is organized the debug information and what does it contain?

How is organized the debug information in a compiled C/C++ program ? What does it contain ? How the debug information is used by the debugger, e.g. gdb and how can I read the debug information better than nm or objdump? ...

GCC Tree STL data containers

Possible Duplicate: remove_if equivalent for std::map Yesterday i wrote a program, which use multiset for storing elements like this: std::multiset < boost::shared_ptr < CEntity > > m_Entities; Then i try to use standard algorithm remove_if like this: std::remove_if(m_Entities.begin, m_Entities.end(), MarkedForDestroy); ...

Speed difference between global and object variable

Is it faster to access a global or object variable? In C++, I'm referring to the difference between ::foo and this->foo In x86 assembler, this basically translates to mov eax, offset foo vs mov eax, dword ptr[edx+foo] All data in both cases is expected to be in cache. (I know the difference if any will be tiny, and one shou...