c++

Linking problems template with return

I'm having some problems on returning the parameter of a method as a template, look: // CTestClass.h template<class T> class CTestClass { public: T getNewValue(); }; // CTestClass.cpp template<class T> T CTestClass<T>::getNewValue() { return 10; // just for tests I'm returning hard coded 10 } // main.cpp int _tmain(int argc...

Linux tool to check spelling of comments in c/c++ source code

What software do you suggest to check spelling of comments contained in c/c++ source code (especially doxygen comments)? I'm looking something that will parse only comments so I can easily find mistakes and correct them. The question is general but to be more specific - I'm using CodeLite IDE. ...

Building legacy Turbo C++ Code

I am looking to revive some old C++ code, developed in Turbo C++ for DOS. It's a console-based text game. This app makes heavy use of conio.h - the Turbo C-specific functions (I think) gotoxy(), window() and the like. I find that Turbo C++ compiler is no longer available for download. Embarcardero/CodeGear/Borland seem to have removed...

include typedef inside a class header

Hi I'm a cpp newbie and i have a little question: this is my header: #ifndef TIMING_H #define TIMING_H #define MAX_MESSAGES 1000 typedef Message* MessageP; //inside the class? class Timing { public: Timing(); private: struct Message { Agent *_agent; double _val; }; MessageP* _msgArr; int _waitingMsgs; }; my questio...

Cannot deallocate mem.

Why in this code (this is just working code and not fully exception safe) I'm getting an assertion error: HEAP_CORRUPTION_DETECTED ... class Allocator { public: explicit Allocator() { std::cout << "Allocator()" << '\n'; } virtual ~Allocator() { std::cout << "~Allocator()" << '\n'; } tem...

Mixing Qt threads with COM threads

I'm working on a little project that uses DirectShow/COM for capture, and DShow makes callbacks using its own threads when my application gets imaging data. I'm also using Qt in my project, and I'm wanting to use Qt for synchronisation and thread-safety. I'm wondering how I can use Qt Threads in this case. I understand I can also use W...

How to pass a pointer to a dynamic array to a void function?

Updated question to reflect answers and my research Thanks casablanca and wallyk for answering. Success!! I ended up having to edit my strcpy and strcat as well as changing my Displayname(char c_fullname) function and researching some more about the additional errors (both complier and runtime) I was getting, but now I have working code...

cannot convert int to int *

#include "stdio.h" #include "conio.h" void swap(int *x,int *y); void main() { int a=10,b=20; swap(a,b); printf("value of a=%d and b=%d"); getch(); } void swap(int *x,int *y) { if(x!=y) { *x ^= *y; *y ^= *x; *x ^= *y; } } // I'm getting .. cann't convert int to int * ... can anybody tell me why ...

I'm a beginner programmer using C++.

I just started programming yesterday, I'm using the C++ language and i was wondering if anyone here could help me get off on the right foot, thanks! ...

Mastering C++ to prepare for my second year: How?

Hey everyone, I'm going to my second year of Computer Science at a local University, in which C++ is a large part of the education, but as they only give an introductory course in the first year (basics, pointers, creating a linked list and an implementation of a game like Mastermind), I'd like to program a bit in my free time to crank ...

Audio Recording and playback VC++

Hi folks I am planning on recording audio, and later play it back, for on of my projects. The requirement is that it should be c++ ( Visual studio 2008 ) compatible. Rest of our application is mostly in silverlight/ VC++. I have worked with NAudio before in C#, but nothing on vc++. I would like to know what is best suited for my needs...

i want to know if the ide we use contains linker or not

Is the Linker part of the Operating System or the Compiler/IDE? ...

int transforms into int& ?

code snippet: // some code SDL_Surface* t = Display->render_text(text); int z=100; Display->blit_image(t,z,100); // some more code does not compile because z magically changes to an int&, file.cpp:48: error: no matching function for call to ‘display::blit_image(SDL_Surface*&, int&, int) how can this happen? post scriptum: the follow...

Placing the \a on the output stream does not produce a sound

This was prompted by some experimenting with C/C++; neither the statement printf("\a"); nor the statement cout << "\a"; produce an audible bell sound. How is the \a supposed to function . . . ...

Algorithm to only draw what the camera sees?

I'm making a 3D FPS with OpenGL and here is the basics of how it works. The game is a 3D array of cubes. I know the location of the player's current cube, aswell as the camera x,y,z and I know the x, y, z rotation of the camera too. Right now I just make a square around the player and render this and then add distant fog. The problem tho...

How can I tell if a const char* points to a valid string?

std::string str = "string": const char* cstr = str.c_str(); str.clear(); //here, check if cstr points to a string literal. How do i check if cstr still points to a string when running the program in debug or release mode? Would there be a way to determine this using exception handling in C++? ...

Why does the Python/C API crash on PyRun_SimpleFile?

I've been experimenting with embedding different scripting languages in a C++ application, currently I'm trying Stackless Python 3.1. I've tried several tutorials and examples, what few I can find, to try and run a simple script from an application. Py_Initialize(); FILE* PythonScriptFile = fopen("Python Scripts/Test.py", "r"); if(Pyth...

Is there a structure in Python similar to C++ STL map?

Is there a structure in Python which supports similar operations to C++ STL map and complexity of operations correspond to C++ STL map? ...

How to return the last three values of a vector?

Hi, I'd like to place the last three values of vector v_2 in three variables (one value per variable). Is there a faster or simpler way to do this? struct Desempenho { double maximo; }; double ultimo, penultimo, antepenultimo; Desempenho d; int n (0); vector<Desempenho> v_2; d.maximo=1.1; v_2.push_back(d); d.maximo=2.2; ...

OpenCV Foreground Detection slow...complicated question or?

Hi, I am trying to implement the codebook foreground detection algorithm outlined here in the book Learning OpenCV. The algorithm only describes a codebook based approach for each pixel of the picture. So I took the simplest approach that came to mind - to have a array of codebooks, one for each pixel, much like the matrix structure und...