c++

using unix system calls in cpp

Hi All, I am new to cpp, I have a small problem, I have a cpp file and it contains open(), read() & close() & some other methods as public members. Now I wanted to use the 'read' unix system call in one of the methods But if I do so (in some method) its pointing to class member variable 'read()' and gives compilation error. So, how to u...

cout fail when used cin after redirect console stream

Hi to all. I want to redirect console streams to cin,cout and cerr. (its a gui application) Well, I have written this class wich do this but when use cin, cout works no more. GetLastError says me INVALID_HANDLE VALUE Can you explain me how fix this ? Thanks Kconsole.h class Kconsole { public: Kconsole(); ~Kconso...

Read from stdin

It seems as if read(0, buffer, 255) always returns 1 when reading. In my program I direct input through the pipe into this program, but I noticed that it always returned a 1. Why is this? Is there a better way of doing this? At the same time, it seems to fill up the buffer properly, past the 1 char. Thank you in advance! ...

Pointers's pointer c++ char intialization

I'm with a doubt In initialization of this in C++: char** A_Function() { char** charList = new char*[2]; charList[0] = "abcde"; charList[1] = "fghij"; return charList; } There's no problem "on compiling this code", but I'm not sure about the behaviour. 1 - the char list: char* is on heap ok? 2 - the charList[n_positio...

designing a game c++

ok im gonna be using directx maybe 9. I have designed two other games they were too simple im asking how game is designed like they make one file that includes menu codes and the all level codes......... thanks ...

Functions with const arguments and Overloading

Was tryin out the stackeroverflow qn so it got me thinking why not overload the the function and I came up with a slightly different code but it says the function cannot be overloaded. My question is why? or is there a another way? #include <iostream> using std::cout; class Test { public: Test(){ } int foo...

Low latency distributed cache for Java & C++ Object

[Background] I am working on a java server side process which for the signal analysis / image processing. The main server process will accept requests / input parameters (XML / Image) from users. It will then distribute request / input to multiple processing engines. The processing engines are written in Java. They will perform the JN...

Problem with istream::tellg()?

I'm reading data.txt: ////////////////////////////////////////////////// data.txt: ////////////////////////////////////////////////// MissionImpossible3 3 TomCruise MaggieQ JeffChase Here's code: #include <iostream> #include <fstream> #include <string> using namespace std; int main() { ifstream fin("data.txt"); string FilmName,...

C++ Linked List Runtime Error: Unhandled Exception - Writing Location Violation

I am trying to build my own implementation of a linked list in C++. My code is compiling but apparently there is some issue with my pointers referring to invalid memory addresses. Here is my implementation: #include <iostream> #include <string> using namespace std; class Node { private: string _car; Node* nextNode...

Implementing Exception class in C++

So, I am try to write a simple base Exception class for C++, based on the Java Exception class. I'm sure there are great libraries out there already, but I am doing this for practice, not production code, and I'm curious and always looking to learn. One of the things the Java's Exception does, which I would like to also implement, is the...

How to specify user defined type parameters in COM interface definition?

One of my COM interface methods needs a parameter of user defined type as below: [uuid(58ADDA77-274B-4B2D-B8A6-CAB5A3907AE7), object] //Interface interface IRadio : IUnknown { ... HRESULT test_method2(someUDT* p2p_UDT); ... }; How could fit the definition of the someUDT in the *.idl file? The someUDT type is a ...

Which library I need to add? : error LNK2019

Error 20 error LNK2019: unresolved external symbol "public: __thiscall CAnyseeUSBTVControllerDlg::CAnyseeUSBTVControllerDlg(class CWnd *)" (??0CAnyseeUSBTVControllerDlg@@QAE@PAVCWnd@@@Z) referenced in function "int __cdecl Init(void)" (?Init@@YAHXZ) anyseeUSBTVControllerDlg.obj anyseee30 I have this error when I...

Showing .NET child window under Win32 unmanaged host

I am writing now plugin for FL Studio 9. I have sdk which is intended to work fine with MFC or Win32 Visual C++ 2008 Project. The question is how to make CLR C++ plugin work in Win32 Application in general? I've build the plugin correctly - it is loaded by FL Studio, but only one thing which works is plugin Width and Height properties of...

Pass an absolute path as preprocessor directive on compiler command line

Hi all, I'd like to pass a MSVC++ 2008 macro into my program via a /D define like so /D__HOME__="\"$(InputDir)\"" then in my program I could do this cout << "__HOME__ => " << __HOME__ << endl; which should print somethine like __HOME__ => c:\mySource\Directory but it doesn't like the back slashes so I actually get: __HOME__ ...

How to find why my application becomes unresponsive at unaccessible customer sites

My application is deployed at customer sites, that I can not access, and has no internet connection. There are complains that in serveral sites, once in a week or so, the application become unresponsive, so that the operators need to kill and restart it. We were unable to observe it in our site. Is there something I can do that may he...

Microsoft ATL equivalent to Borland OleCheck function

Borland C++ Builder provides the function OleCheck(HRESULT Result);. Its description in the documentation is this: OleCheck is used to wrap many COM routines, so that if that routine fails, users will have an opportunity to handle it in the resulting exception that is raised. If ECode is a value less than zero, OleCheck raises...

C++ [] mapping, possibly through templates

Hi, I have a little problem in C++ I don't know how to solve. The first part of the problem is to access an element in a struct via [], or better, to map [] to a subelement. My struct looks like this: struct e { std::string content; std::string name; std::map<std::string, std::vector<e> > elements; }; If I want to access ...

Writing algorithm functions for STL

I have a std::set which is of type point struct point { int x; int y; int z; }; Suppose I want to perform three different operation on each variable in set i.e Find the smallest number from x variables. Get missing elements from y variables using set difference. Get product of all z variables. At this point, should i use thr...

Is there any good known file based key->value datastructure available in c++?

Is there any good file based key->value data-structure available in c++. similar to std::map(template based) with a insert/delete/get of O(logn). ...

Overloading operator new [] in C++ fails with Visual C++

Hi, I have code that overloads operator new. The code below works fine under Linux (gcc4x) but not Windows ( Visual C++ 2008 Express Edition) The code under Visual Studio 2008 Express Edition reports error C2660: operator new[] : function does not take 1 arguments Thank you very much! class dummy{}; void* operator new[] (size_t si...