c++

Slow response from getaddrinfo

I'm using getaddrinfo to do DNS queries from C++ on Windows. I used to use the Windows API DnsQuery and that worked fine, but when adding IPv6 support to my software I switched to getaddrinfo. Since then, I've seen the following: My problem is that some times getaddrinfo take very long time to complete. The typical response from getaddr...

encoding conversion from JIS X 208 to UNICODE

How can I convert a JIS X 208 encoded string into UNICODE in C++? A VC++ specific answer would be helpful. The bigger problem that I am finding difficulty in understanding is that there are too many encodings for Japanese characters. JIS itself has many versions, then there is Shift-JIS. It would be great if some one could point toward...

will there be any performance issue - if i use cpp inside c# ?

Hi all, i do have a cpp program which does text processing on 40k records. we developed this program in cpp because we thought it would be faster. then i used/executed this cpp part inside my c# program using the process-execute but the problem is we feel like we lost control of the execution flow.. cant able to log-in the ha...

Returning a pointer vs. passing a reference to an object to store the answer in C++

I have general question regarding the use of pointers vs. references in this particular scenario. Let's say that I have a function that is going to do some computation and store the value inside an object for later use by the caller. I can implement this by using either pointers or references. Although, I would prefer using references ...

How could I apply a genetic algorithm to a simple game that follows rollercoaster tracks?

I have free-rein over what I do on a final assignment for school, with respect to modifying a simple direct-x game that currently just has the camera follow some rollercoaster rails. I've developed an interest in genetic algorithms and would like to take this opportunity to apply one and learn something about them. However, I can't thi...

Unable to detect what line is causing a syntax error

Howdy! I'm working on an old project from one of my programming courses and having some issues tracking down which line in my code is causing a syntax error. When I attempt to compile the code, Visual Studio tells me that there is a syntax error towards the end of main on the line containing this function call: sortData(carray, numRe...

Need some explanation on compile errors:

The following compile errors is what I have: /usr/lib/qt-3.3/include/qobject.h: In copy constructor Product::Product(const Product&): /usr/lib/qt-3.3/include/qobject.h:211: error: QObject::QObject(const QObject&) is private Product.h:20: error: within this context HandleTCPClient.cpp: In member function int Handler::HandleTCPClient(int,...

Dynamic Allocation of an Array of Pointers to Objects

Hi all, This question is in C++. I am trying to dynamically allocate an array of pointers to objects. I know I can use a vector container but the point of the exercise is not to... Here is the code: void HealthClub::AddHealthClubDevice ( char* HealthClubDeviceName ) { //We added NumberOfDevices as ...

Unable to correct error in C++ code

Hi all, I am unable to detect the error in the following C++ program. The code defines a Graph class. #include <vector> #include <list> using namespace std; class Neighbor { public: int node_id; float edge_cost; float price; Neighbor(int&,float&,float&); }; Neighbor::Neighbor(int& node_id, float& edge_cost,float& price) { ...

Stack allocation limit for programs on a Linux 32 bit machine

In C++ how much can the stack segment grow before the compiler gives up and says that it cannot allocate more memory for stack. Using gcc on a linux (fedora) 32 bit machine. ...

integer automatically converting to double but not float

Hi all, I have a function like below: void add(int&,float&,float&); and when I call: add(1,30,30) it does not compile. add(1,30.0,30.0) also does not compile. It seems that in both cases, it gets implicitly converted to double instead of float. So, do you suggest that it is better to re-define add as add(int&,double&,double&)? Is...

is it possible to spoof ip behind NAT?

hello! is it possible to spoof the source ip if im behind a router that is using NAT? if not, how do botnet programmers manage to make a SYN flood from their slaves? doesnt most of the home/business networks use NAT? ...

Show colored compilation errors in C++ on Terminal

Hi all, Is there any way to show compilation errors in colors on the terminal? I mean when we do "g++ filename.cpp", is there a way to show the compiler messages in colors? By default it is always in Black color. But if we have a lot of error messages, then it helps to have them in different colors (just like the code is highlighted in ...

What is ->* operator in C++?

C++ continues to surprise me. Today i found out about the ->* operator. It is overloadable but i have no idea how to invoke it. I manage to overload it in my class but i have no clue how to call it. struct B { int a; }; struct A { typedef int (A::*a_func)(void); B *p; int a,b,c; A() { a=0; } A(int bb) { b=b; c=b; } ...

(c)make - resursive compile

Hello! Let's assume I have directories like: dir1 main.cpp dir2 abc.cpp dir3 def.cpp dir4 ghi.cpp jkl.cpp And let's assume that main.cpp includes dir2/abc.cpp and dir3/def.cpp, def.cpp includes dir4/ghi.cpp and dir4/jkl.cpp. My question is, how can I have one Makefile/CMak...

Strange "type class::method() : stuff " syntax C++

While reading some stuff on the pImpl idiom I found something like this: MyClass::MyClass() : pimpl_( new MyClassImp() ) First: What does it mean? Second: What is the syntax? Sorry for being such a noob. ...

MSVC Unicode not displaying English

Hello. My problem is that my Unicode c++ program that I'm writing in MSVC express is displaying all strings in an Asian font. I cannot myself figure out how to make it display in English. Thank you for your time. ...

C++ Templates vs. Aggregation

Consider the following piece of code: class B { private: // some data members public: friend bool operator==(const B&,const B&); friend ostream& operator<<(ostream&,const B&); // some other methods }; template <typename T=B> class A { private: // some data members vector<vector<T> > vvlist; public: /...

Visual C++ Team Test problems

I am trying to get some unit tests for native C++ running with Visual Studio Test Suite. I have just a single, simple class named "Shape". I followed a tutorial and did the following steps: Created a "ref class" wrapper called "MShape" for the native class I want to test Changed configuration type to .dll Changed CLR support to /CLR Se...

QTimer & Select use. Need to get auction time working.

Currently I am having issues with QTimer. I am trying to make each "Product" have a timer and so it will let my "Handler" know that the auction time of the product has ended. The problem that I am having is that from my test, it doesn't seem to print "Timer started". This is part of my socket programming project. I use select because I ...