c++

OpenCV2.1, map function? accessing each pixel?

Hi, I have a function that I would like to apply to each pixel in a YUN image (call it src). I would like the output to be saved to a separate image, call it (dst). I know I can achieve this through pointer arithmetic and accessing the underlying matrix of the image. I was wondering if there was a easier way, say a predefined "map" fu...

mixing fstream streams issue even when closed streams

I am having problems with the code bellow. It can write fine if i kill the read section. It can read fine if i kill the write section and the file has already been written. The 2 don't like each other. It is like the write stream is not closed... though it should be. What is wrong? #include "stdafx.h" #include <iostream> #include <...

C++ command line argument comparison

I am doing some validation of the arguments passed by command line in C++ and am having some difficulties. I am doing like so ./a.exe inputfile.txt outputfile.txt 16 flush_left And I am trying to do the validation like so if(argv[4] == "flush_left" || argv[4] == "flush_justify" || argv[4] == "flush_right"){ And its not working out...

Calculating total return with compound interest

So, I'm trying to figure out the total amount of return from an investment of £5 with a daily interest rate of 1.01%. Obviously, I am wanting the compound interest rate, so I have this so far: int main() { double i = 500; int loop; int loopa; double lowInterest; double highInterest; lowInterest = 1.01; high...

void return value from a function used as input to a templated function is seen as a parameter.

Say you have some target class with some methods on it: class Subject { public: void voidReturn() { std::cout<<__FUNCTION__<<std::endl; } int intReturn() { std::cout<<__FUNCTION__<<std::endl; return 137; } }; And a Value class (similar in concept to Boost.Any): struct Value { Value() {} Value( Value const & orig ) {} temp...

Delphi/C++ DLL problem - unsigned long vs unsigned int?

(SOLVED: See self-reply. Thanks to those that answered). I'm having a weird problem with a C++ DLL I am loading dynamically into my Delphi 6 Pro program. One of the function calls in the DLL is: __declspec(dllexport) int foo(unsigned int A, unsigned long bitsetVector); I have the function pointer cast in my Delphi function as: foo ...

Existing C++ *nix system library?

There are several good cross-platform libraries, by which we usually mean something that wraps the commonalities of Windows and *nix. Is there anything for developers that don't really care about Windows but want the benefits of C++ wrapping *nix system calls? I am thinking of a library that reduces the tedium of struct setup, checking...

new to C++, confused about separating code [answered]

Hi, I am new to C++, and I'm having trouble segmenting my code. Here is my setup: A main.cpp that calls function that takes 2 int and 1 char* and returns int A function.h that contains, among other things, a function prototpye int function(int a, int b, char* c); A function.cpp that contains the actual function definition. I have...

Why would a copy constructor have more than one parameter?

$12.8/2 - 'A non-template constructor for class X is a copy constructor if its first parameter is of type X&, const X&, volatile X& or const volatile X&, and either there are no other parameters or else all other parameters have default arguments (8.3.6).106)' So far, I have not come across any example of a situation w...

GPA calculator/ adding outside a loop

Greetings, I'm just looking for a bit of help here. Here's the prompt: For research purposes the admissions officers of your local university wants to know how well female and male students perform in certain courses. The user enters the number of courses to be considered. The student's data for each course is provided as a GPA followe...

selecting the pixels with highest intensity in opencv

can anyone help me to find out the top 1% (or say top 100 pixels)brightest pixels with their locations of a gray image in opencv. because cvMinMaxLoc() gives only brightest pixel location. Any help is greatly appreciated. ...

Foreach loop in C++ equivalent of C#

Hi, Can any body convert this code to C++ string[] strarr = {"ram","mohan","sita"}; foreach(string str in strarr) { listbox.items.add(str); } Thanks in advance. ...

Does this generate a memory leak?

void aFunction_2() { char* c = new char[10]; c = "abcefgh"; } Questions: Will the: c = "abdefgh" be stored in the new char[10]? If the c = "abcdefgh" is another memory area should I dealloc it? If I wanted to save info into the char[10] would I use a function like strcpy to put the info into the char[10]? ...

How can I get the class name from a C++ object?

Is it possible to get the object name too? #include<cstdio> class one { public: int no_of_students; one() { no_of_students = 0; } void new_admission() { no_of_students++; } }; int main() { one A; for(int i = 0; i < 99; i++) { A.new_admission(); } cout<<"class"<<[classname]<<" "<<[objectname]<<"has "...

How to increase thread priority in pthreads?

I am using pthread in Linux. I would like to increase the thread priority by setting the parameters sched_param.priority. However, I could not find much info from the net regarding the range of the thread priority I could set, or about the description of the thread priority. Also, I would like to know about the relative thread priority ...

How to go about a platform independent E-Book Reader in C/C++?

Hi, I'm trying to develop an ebook reader(for mobile devices) which is platform independent. Currently my focus is epub only. As a proof of concept, we were able to make a basic epub reader for android platform, using the functionalities provided by the platform itself(using webview, Xml Parser, Unzipper etc). But now we want to make i...

How to have a Struct with template with a class

With this code (just a class of test): typedef unsigned short UInt16; template<class T> class CClass { public: SValue* getNewSValue(void); private: typedef struct { T *mValue; T *next; T *previous; UInt16 index; } SValue; }; template<typename T> SValue* CClass<T>::getNewSValue(void) { re...

drawing outside client area, winAPI

How would I draw outside the client area of a window, and on the title bar. I know it can be done, but I am unsure of how to implement this effectively. Think google chrome, where the tabs are on the title bar. ...

Tridiagonal matrix class in Boost c++

Does boost provide any classes to implement a tridiagonal matrix? ...

Whole - Part design advice

I have two classes. One is the Part class, its purpose is to deal with visual requirements. The other is the Whole class, its purpose is to deal with operational requirements. Of course Whole class has Part class data members. I want to manage Part class operational requirements with Whole class and Whole class visual requirements with P...