c++

In C++ why can't I write a for() loop like this: for( int i = 1, double i2 = 0; .....

or, "Declaring multiple variables in a for loop ist verboten" ?! My original code was for( int i = 1, int i2 = 1; i2 < mid; i++, i2 = i * i ) { I wanted to loop through the first so-many squares, and wanted both the number and its square, and the stop condition depended on the square. This code seems to be the cleanest ...

Display PNG on Visual Studio form

I'm working on a C++ application in Visual Studio (non-MFC) and was surprised to find that I can't add a PNG image to a dialog in the designer which seems a little backward as I can in most other IDEs that I've used. So either a) there is something I'm missing or b) there is a way to do it with code. I'm hoping that it's a but b would be...

OpenGL Problems When Compiling Across Linux Distributions

I recently wrote a maze game in opengl (using freeglut) that works fine when built in Ubuntu or Cygwin, but when built on Fedora Core 12 with freeglut, the game falls apart, and my professor can't see a thing when he builds it on his machine (the OS of which he has failed to disclose). Also, on previous assignments, I got flickering eve...

Points to consider when implementing shared memory

I am planning to implement boost's shared memory between a Server (C++) and client (C# application). There is only reader and one writer and frequency of data share (read and write) is thousands of time per millisecond. What are the risks involved? ...

CStdIoFile::ReadString reverts to previous position?

So, I've got a class that looks sort of like this: class A { CStdioFile FIN; CString Line; void DoStuff(); void DoOtherStuff(); }; A::DoStuff() { //assume FIN has already been opened while(FIN.ReadString(Line)) //<----Weirdness happens here after first iteration { //do some stuff ... ...

Dynamic vs non-dynamic class members

In C++, ff I have a class that needs to hold a member which could be dynamically allocated and used as a pointer, or not, like this: class A { type a; }; or class A { A(); ~A(); type* a; }; and in the constructor: A::A { a = new type(); } and destructor: A::~A { delete a; } are there any advantages or ...

Cannote find PDB Visual Studio 2010

Hi guys! I did my Hello World! program in Visual Studio 2010 C++, it does work all ok (except that if I enter 2 times it will close, it's normal?) But there is a little "error message" or whatever that appear in the debug log: 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file What does that mean? You can see my code...

Add elements and clear a vector of pointers in C++

I would like to add 2 elements to a vector<Node*> and then clear all the elements and release the memory. Does this code do that in a right way? #include <stdlib.h> #include <iostream> #include <vector> using namespace std; class Node { public: int value; // ...and some other fields and methods... }; int main(int argc, char**...

going from Inverse discrete FFT to spectrogram

I need to locate some generic C++ library that takes the inverse fft output (fftw_complex format, i.e. two doubles) and converts this data to an image file such as png. I can waterfall the dffts to obtain the 2d data (and use 10log10(re*re+im*im) to obtain magnitudes for each frequency component) but I don't know which image library wil...

Retrieving data type information for columns in an Oracle OCCI ResultSet

After sending a simple query via OCCI (example: select * from ALL_USERS) I'm in the need to know the datatype for the column, for the moment I've been playing with the ResultSet::getColumnListMetaData() method without success. Questions: 1. How can I get the datatype by using the aforementioned method and the MetaData class? 2. Is ...

Creating a C++ COM client for C# COM server

I have a C# ComServerProject that implements an out-of-proc COM server, and I've selected the option "Make assembly COM-visible" on server project's "Assembly Information" dialog. In the same solution I have a C++ ComClientProject that should use the COM interface defined in ComServerProject. However, I don't know how to actually use th...

How commonly used are the xilinx chips?

I'm beginning to learn embedded with C (and maybe some C++) and someone from the office said they're willing to donate a free xilinx chip they've got sitting on their shelf. I was thinking more along the lines of an Arduino, especially that the Arduino tutorials and sample projects are abundant. Can someone confirm how xilinx chips co...

dlopen/etc doesnt compile. Unresolved symbol

Hi. I am exploring the usage of dynamic stuff. So far My program (main.cpp) doesnt want to compile, becouse dlopen&Co are "unresolved". I DID include dlcfn.h. I need the answer as soon as possible, becouse I have to go home in 30mins(doing rapidly other stuff also). The correct error message might be "undefined", but this is not my com...

Which complements Python best: Java, C, or C++?

I am in the process of applying to a Computer Science program which requires students to have at least an intro-level exposure to either Java, C or C++. I have some experience with Python and I would prefer to continue working in Python before starting another language; however, the professor said that Python was too light, i.e. "it's j...

How do I properly port Win-only function GetMultiByteString?

I'm porting code originally Windows-only to cross-platform friendly code; one particular stumbling block is trying to convert calls to the Windows Unicode function "GetMultiByteString" (and any related functions) to the more portable wchar-based functions. I'm having little success with it, as using wchar results in premature loop termin...

erase max element from STL set

This is a follow-up on a previous question I had ( http://stackoverflow.com/questions/3313301/complexity-of-stl-max-element ). I want to basically pop the max element from a set, but I am running into problems. Here is roughly my code: set<Object> objectSet; Object pop_max_element() { Object obj = *objectSet.rbegin(); set<Obj...

Why is vector<Data*>::iterator valid and vector<Data*>*::iterator not?

I have these three related class members: vector<Frame*>* poolFrames; vector<Frame*>*::iterator frameIterator; vector<vector<Frame*>::iterator>* poolFrameIterators; When I compile, gcc tells me error: invalid use of ‘::’ error: expected ‘;’ before ‘frameIterator’ In reference to the middle line, where I define frameIterators. ...

Threading Architecture Question C++ Message Passing

Simple question, I think. I have one thread that responds to a callback that is called when a user connects via TCP. That callback wants an answer if I accept or reject the login. Problem is I have to send a login request to a security server via asynchronous message passing and wait for a response. What is the best way to handle t...

C++ printf large buffer

The problem I am having is printf doesnt print all the data that is being returned from a client response. (verified data is being sent back via packet sniffer) #define MAXBUFFER 24576 char buffer[MAXBUFFER]; ...... datastream = read(sock,buffer,MAXBUFFER - 1); printf("%s",buffer); ...... What is the best approach to printing all t...

Referencing a member of a member in template

I'm using boost::multi_index_container and I'm trying to refer to a member of a member in a template argument, but it's unclear how to do this: struct Foo { int unique_value; }; struct Bar { Foo foo; double non_unique_value; }; // I want to refer to some_value in a template argument: multi_index_container<Bar, boost::multi...