c++

Interfacing GPIB with Qt

Hi, I was wondering if it is possible to interface with GPIB Instruments by using C++ and Qt. If it is possible, can anyone tell me how easy it would be and/or point me in a direction for a tutorial or examples? Thanks a lot. ...

Why not mark everything inline?

First off, I am not looking for a way to force the compiler to inline the implementation of every function. To reduce the level of misguided answers make sure you understand what the inline keyword actually means. Here is good description, inline vs static vs extern. So my question, why not mark every function definition inline? ie ...

What is a C/C++ data structure equivalent in Javascript?

Lets say I have the following in C struct address{ char name; int id; char address; }; struct address adrs[40]; //Create arbitrary array of the structure. 40 is example adrs[0].name = 'a'; id[0] = 1; ... What is the equivalent way of defining and creating array of a user defined structure. Thanks ...

Efficient data structure for searching numbers and strings

Hi, I have a scenario where in strings and numbers are combined into a single entity. I need to search based on the string or the number. How do I go about with the data structure for this? I thought of coming up with a hashing for strings and search tree approach for numbers. Can you please comment on my choice and also suggest better s...

"Expected ; before..." with template function to print std::vector<Whatever>

Hi all, I'm trying to make a pretty-printer for std::vector's of whatever ... doubles, my own custom classes... anything that has a friend std::ostream& operator<<. However, when trying to compile the following function: template <typename T> std::ostream& operator<<(std::ostream& os, std::vector<T> const& list) { std::vector<T>::co...

Debugging string from resource with assembly

Here is my issue. I'm trying to learn how to do debugging in assembly with OllyDBG. Usually, when a string is literally in the application, I can find something that points to it, however, this string is from the resource file (when doing WinAPI programming, a resource, .rc, is used). Therefore, given that it is in resource data, how can...

bool from a struct lead to "error: expression must have class type"

I have a struct defined as struct sData{ idx * id; int * stime; bool * result; unsigned int N; }; Then the code that uses it in numeric compute(numeric e, sData swabs){ numeric cache=0.0; int sid=0; while(sid<swabs.N){ if(swab.result[sid]) cache += log(e); else cache += log(1.0-e); sid += 1; } retu...

if/else format within while loop

while(true) { cout << "Name: "; getline(cin, Name); if(Name == "Stop") break; cout << "Additional Name - Y/N: "; getline(cin, additional); if (additional == "Y") cout << "Additional Name: "; getline(cin, Name2); else cout << "Location: "; getline(cin, Location); if(Location == "Stop") break; } chi...

Syntax for calling templated method

Hi, I'm wondering what's the proper syntax for calling template method given as: struct print_ch { print_ch(char const& ch) : m_ch(ch) { } ~print_ch() { } template<typename T> void operator()() { std::cout << static_cast<T>(m_ch) << std::endl; } private: char m_ch; }; I came up with sth like this: ...

Why should the member function declarations of a class template be all well-formed?

OK, suppose I want to check whether the template parameter has a nested type/typedef XYZ. template <class T> struct hasXZY { typedef char no; typedef struct { char x[2]; } yes; template <class U> static yes f(typename U::XYZ*); template <class /*U*/> static no f(...); enum {value = sizeof(f<T>(0))=...

Is possible to get automatic cast from user-defined type to std::string using cout?

As in the question, if I define a string operator in my class: class Literal { operator string const () { return toStr (); }; string toStr () const; }; and then I use it: Literal l1 ("fa-2bd2bc3e0"); cout << (string)l1 << " Declared" << endl; with an explicit cast everything goes right, but if I remove the (string) the c...

OpenFileDialog->DialogShow() results cause errors in SQLite

I have a program that accesses a database using SQLite. When I open a OpenFileDialog or a SaveFileDialog before I do the SQLite call: result = sqlite3_prepare_v2(databaseConnection,converted,10000,&stmt,&strptr); and choose "Cancel", everything works okay (result == SQLITE_OK) but when I choose "Open", even if I don't do anything with...

Can child templates stored in a base class array, use an overloaded virtual function?

In hope to simplify a homework problem dealing with inheritance, I thought it might be better to use polymorphism to accomplish the task. It isn't required, but makes much more sense if possible. I am, however, getting symbol errors making it work as I thought it should or just the base class definition is called. I want the overloade...

Example for rendering with Cg to a offscreen frame buffer object

I would like to see an example of rendering with nVidia Cg to an offscreen frame buffer object. The computers I have access to have graphic cards but no monitors (or X server). So I want to render my stuff and output them as images on the disk. The graphic cards are GTX285. ...

C++ How can I convert a date in year-month-day format to a unix epoch format?

I need to convert a given date to an int containing the number of milliseconds since Jan 1 1970. (unix epoch) I tried the following code: tm lDate; lDate.tm_sec = 0; lDate.tm_min = 0; lDate.tm_hour = 0; lDate.tm_mday = 1; lDate.tm_mon = 10; lDate.tm_year = 2010 - 1900; time_t lTimeEpoch = mktime(&lDate); cout << "Epoch: ...

Visual Studio 2010 - LINK : fatal error LNK1181: cannot open input file " ■/.obj"

I have VS 2010 on Windows 7. I create a new project, chose c++ language, Win32 project, DLL, Export symbols, then finish. Now when I compile the project without any changes to what VS generates, I get... LINK : fatal error LNK1181: cannot open input file " ■/.obj" I also have VS 2008 install on the same machine. I follow the same st...

How can I get the current instance's executable file name from native win32 C++ app?

How can I get the current instance's file name & path from within my native win32 C++ application? For example; if my application was c:\projects\testapps\getapppath.exe it would be able to tell the path is c:\projects\testapps\getapppath.exe ...

Syntax Error: identifier 'Edge' ?

At the consturctor Node = new Node[numberOfNodes]; and Edge = new Edge[numberOfEdges]; gives identifier error? what's the wrong with it ? typedef struct node { int id; int x; int y; } Node; typedef struct edge { int id; Node node1; Node node2; } Edge; class graph { private: int numberOfNodes; int numberOfEdges; int *Node; in...

what's meaning that sign of assignment.

hi, i don't understand assignment in the following line. i think, setBit is a function but it's assigned a value. bool setBit(const unsigned int which) = 0; ...

Finding amount of RAM using C++..

How would i find out the amount of RAM and details about my system like CPU type, speed, amount of physical memory available. amount of stack and heap memory in RAM, number of processes running. Also how to determine if there is any way to determin how long it takes your computer to execute an instruction, fetch a word from memory (wit...