c++

Cannot find default constructor

My error occurs on line 191 and 156. For some reason it is saying it cant find the default constructor when I have supplied the right amount of parameters. The error it is giving me is "Cannot find default constructor to initialize base class" code: http://pastebin.com/WLMvBMyy If anyone could offer any input it would be greatly appre...

Efficient method of passing callback member function

I'm designing a method for an input handler class. Here is some pseudo code... void InputHandler::ScanEvents( boost::function1< void, std::string& > &func ) { // Scan keys, determining string to pass // If string found, call func with string as its argument on object tied to func } I'm not exactly sure how to implement this, o...

How to find the no of elements in an string array (the string is passed to a function).

#include<iostream> #include<string> using namespace std; class Prerequisites { public: void orderClasses(string* Input); }; void Prerequisites::orderClasses(string* Input) { // Need to find the length of the array Input } int main() { Prerequisites A; string classes[]={"CSE121: CSE110", "CSE110:"...

(C++ header file question) Can someone help clairify how header files work?

Hi I've been working with C++ for a good couple of weeks now, but the mechanism behind header files (or the linker I suppose?) confuses the heck out of me. I've gotten in the habit of creating a "main.h" to group my other header files and keep the main.cpp tidy, but sometimes those header files complain about not being able to find a di...

Nested type as function argument

I have the following template class: template<class T> class C { typedef C_traits<T> traits; typedef typename traits::some_type type; //... // use 'traits' and 'type' a lot //... }; where C_traits is a template struct that has a typedef for some_type that is different for each specialization of the ...

Type of UTF-16 encoding, using wofstream in Windows

Recently, I want to write a text file in unicode (UTF-16) under Windows. By refering to http://www.codeproject.com/KB/stl/upgradingstlappstounicode.aspx, here is the code I am applying. When I use Notepad to open up the document, here is the display. Newline seems disappear!!! When I use Firefox with UTF-16 encoding selected, here i...

Installing C++ Armadillo library on Mac OS X

I am trying to use the C++ armadillo library (armadillo-0.9.10) on a Mac Pro. I follow the manual installation instruction in the README.txt file. I have modified the config.hpp file to indicate that I have LAPACK and BLAS installed. I then try to compile the examples. I successfully compile and run example1.cpp, but when I try to run...

c++ vector as a parameter Help

I wrote a function to take in a vector, a int position and a int value void add(vector<int>& pro, int pos, int val){ pro[pos] += val; while(pro[pos] > 9){ int carry = pro[pos]/10; pro[pos] %= 10; pos++; pro[pos] += carry; }//while }//function add lets say i have vector<int> list1,list2,pro...

Sometimes my windows handle is good, sometimes it bad

I am confused. Sometimes when I initiate my window, the Handle returned is good. and sometimes its not. Here is my code void GXRenderManager::InitWindows() { WNDCLASSEX wndcex; wndcex.cbSize = sizeof(WNDCLASSEX); wndcex.style = CS_HREDRAW | CS_VREDRAW; wndcex.lpfnWndProc = GXRenderManager::WndProc; wndcex.cbCls...

Creating a menu strip with WinAPI

In .Net there is something called a menu strip. These are more customizable than HMENU's. How could I create one of these in unmanaged C++? Thanks ...

C++ Socket Connection Error

EDIT I've made changes to what I saw below and this is what I have #include <sys/socket.h> #include <netinet/in.h> #include <sys/un.h> #include <arpa/inet.h> #include <netdb.h> #include <string> #include <vector> #include <iostream> #include <cstring> #include <cstdlib> #include <errno.h> using namespace std; string buffer; vector<s...

C++ class redefinition error help

Hi All, I am getting errors like: FxMathFunctions.h: In function 'FxInt32 IMin(FxInt32, FxInt32)': FxMathFunctions.h:13: error: redefinition of 'FxInt32 IMin(FxInt32, FxInt32)' FxMathFunctions.h:15: error: 'FxInt32 IMin(FxInt32, FxInt32)' previously defined here In FxMathFunctions.h I have: 11: struct FxPoint2d; 12: 13: inline Fx...

Calculating both weighted and unweighted statistics with the same boost::accumulator_set?

With Boost's accumulators I can easily calculate statistical quantities for weighted or unweighted input sets. I wonder if it is possible to mix weighted and unweighted quantities inside the same accumulator. Looking at the docs it doesn't seem that way. This compiles fine but produces another result than I would have liked: using name...

Registering derived classes in central list

Hi, I have a central list of implementations of an interface and would like for derived classes to be able to register themselves in that list without having to add them in some central place. For example: // interface.h struct MyInterface; std::vector<MyInterface*>& InterfaceList(); struct MyInterface { MyInterface() { Int...

C++ template specialization of templated types

I'm looking to help users of some of my templated code by using BOOST_STATIC_ASSERT to let them know that they've used an incompatible type with a simpler compile error message than the monster than is currently produced with an incompatible type. The example is a bit too complex to reproduce here, but hopefully this will capture the es...

failure to create a DirectX device and swapchain

I am having issues retrieving a swapchain and device from directx. further info is in the code void GXDX::StartUp(HWND* mainWindow,int w, int h) { //width and height are members of GXDX width = w; //contains the width height = h; //contains the height this->mainWindow = mainWindow; // Is a handle to the main window. i...

How to detect and remove guide lines from a scanned image/document efficiently ?

Hello All For my project i am writing an image pre processing library for scanned documents. As of now I am stuck with line removal feature. Problem Description: A sample scanned form: Name* : ______________________________ Age* : ______________________________ Email-ID: |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_| Note: Following are the f...

Bitwise setting in C++

#define OUTGOING_MASK 0x0c #define OUTGOING_DISABLED 0x04 #define OUTGOING_ENABLED 0x08 #define OUTGOING_AUTO 0x00 #define REFER_SUPPORTED 0x80 Assume support is some value of type int. I have a getter function int get() { if(OUTGOING_DISABLED == support & OUTGOING_MASK) return 1; else if(OUTGOING_ENABL...

twofaced file problem

I'm reading in my program some files from system32 folder; and one of these files (C:\Windows\System32\gdi32.dll) demonstrates a very strange behavior. When I'm reading it from my program, it shows size of 310'784 bytes; and when I view it's size from Explorer, it shows size of 404'480 bytes. How could that be? ...

Terminate existing tcp connection

Hello, Is there a way to kill off an existing connection?? For example, 192.168.1.120 is connected to be via port 8080. I would like to know how to terminate that connection? Many thanks! ...