c++

Problem Initializing an Array Of Structs

I am trying to initialize the following array of the following struct, but my code isn't compiling. Can anybody help me out? The struct/array: struct DiningCarSeat { int status; int order; int waiterNum; Lock customerLock; Condition customer; DiningCarSeat(int seatNum) { char* tempLockName; spri...

syntax for calling virtual functions outside of the class?

Hi there, what is the syntax for defining virtual functions outside the class body? class random{ public: random(int i = 0); virtual ~random(){}; virtual void print() const; protected: int id; }; is it? virtual void random::print() { } ? ...

Multiple Socket Connections

I need to write a server which accepts connections from multiple client machines, maintains track of connected clients and sends individual clients data as necessary. Sometimes, all clients may be contacted at once with the same message, other times, it may be one individual client or a group of clients. Since I need confirmation that t...

VB to c++ or c#?

I am trying to translate this code but I don't understand how to use the GET / PUT part of the code in another language like c++ or c#. This is the code : Private Sub cmd_Click() Dim i As Integer, a As Integer a = 10 For i = 1 To a Dim file As String Open "txt" For Binary As #1 file = Space(LOF(1)) Get #1, , file Cl...

What is a way to fill a multiline editbox with line of text.

What im after is a greyed out editbox you see at the bottom of some programs. A list of results. Im having problems having the text properly formatted. so starting from scratch, how is it usually done? The filling of the half page sized editbox with text. one big long string with line breaks? Results->Text = System::Convert::ToString...

destructor and copy-constructor calling..(why does it get called at these times)

Hello there, I have the following code #include <iostream> using namespace std; class Object { public: Object(int id){ cout << "Construct(" << id << ")" << endl; m_id = id; } Object(const Object& obj){ cout << "Copy-construct(" << obj.m_id << ")" << endl; m_id = obj.m_id; } Object& oper...

C++ corrupt my thinking, how to trust auto garbage collector?

I use to program mainly with C/C++, that's make me dealing with pointers and memory management daily. This days I'm trying to develop using other tools, such as Java, Python and Ruby. The problem is that I keep thinking C++ style, I'm writing code as C++ usually written in almost every programming language, and the biggest problem is th...

Reuse C++ Header files

Guys, I have a Visual C++ solution with 2 projects AlgorithmA & AlgorithmB and both share a common header file RunAlgo.h with the class declaration. Each project in the solution has its own unique implementation for the header file. I am trying to compile a DLL out of the common header file RunAlgo.h and add reference to this DLL i...

Can you recommend a full-text search engine?

Can you recommend a full-text search engine? (Preferably open source) I have a database of many (though relatively short) HTML documents. I want users to be able to search this database by entering one or more search words in my C++ desktop application. Hence, I’m looking for a fast full-text search solution to integrate with my app. ...

recursive typedef

Is the following allowed? typedef Foo<Bar> Bar; My compiler complains that 'class Bar' has a previous declaration as 'class Bar'. ...

How to best integrate generated code

I am evaluating the use of code generation for my flight simulation project. More specifically there is a requirement to allow "the average engineer" (no offence I am one myself) to define the differential equations that describe the dynamic system in a more natural syntax than C++ provides. The idea is to devise a abstract descriptor la...

Qt not displaying PNG images on Linux

Hi, I have a software written using Qt which is meant to work on both Windows and Linux. I use PNG images as icons for my QActions, embedded in a resource. I have the following tree directory: / resources/ icons.qrc image.png Here is the content of icons.qrc: <RCC> <qresource prefix="/resources" lang="fr"> <file al...

How initialize array of classes? (C++)

Hello, I have this class constructor: Pairs (int Pos, char *Pre, char *Post, bool Attach = true); How can I initialize array of Pairs classes? I tried: Pairs Holder[3] = { {Input.find("as"), "Pre", "Post"}, {Input.find("as"), "Pre", "Post"}, {Input.find("as"), "Pre", "Post"} }; Apparently it's not working, I also tried...

OpenGL texture shifted somewhat to the left when applied to a quad

I'm a bit new to OpenGL and I've been having a problem with using textures. The texture seems to load fine, but when I run the program, the texture displays shifted a couple pixels to the left, with the section cut off by the shift appearing on the right side. I don't know if the problem here is in the my TGA loader or if it's the way ...

Where does C++ really shine?

I know C and Python, and I'm moving toward another language for learning purposes. My problem is that I like to learn things with something to do (for example contributing to some project or do something amazing, not boring plain algebra). I would like to hear suggestions about the fields in which C++ shines and where I can find interes...

How to put/get INT to/from a WCHAR array ?

how can I put a INT type variable to a wchar array ? Thanks EDIT: Sorry for the short question. Yes we can cast INT to a WCHAR array using WCHAR*, but when we are retrieving back the result (WCHAR[] to INT), I just realize that we need to read size of 2 from WCHAR array since INT is 4 BYTEs which is equal to 2 WCHARs. WCHAR arData[20...

Is iterator being invalidated?

Is iterator invalidated after: string b "Some string"; auto beg_ = b.begin(); auto end_ = b.end(); b.erase(beg_); ...

Using custom coordinates with QGraphicsScene

I am experimenting with a WYSIWYG editor that allows a user to draw shapes on a page and the Qt graphics scene support seems perfect for this. However, instead of working in pixels I want all my QGraphicsItem objects to work in tenths of a millimetre but I don't know how to achieve this. For example: // Create a scene that is the size...

Need Language/Career Path Advice

I am interested in getting a few Microsoft Certs and I am currently facing the option for .NET Framework app development language. My choices are C++, C#, and Visual Basic. I have some experience with C, Java, and Visual Basic .NET primarily through college. I honestly would like to know what the best would be for developing stand-alo...

QTableWidget::itemAt() returns seemingly random items

I've just started using Qt, so please bear with me. When I use QTableWidget->getItemAt(), it returns a different item from if I used currentItemChanged and clicked the same item. I believe it's necessary to use itemAt() since I need to get the first column of whatever row was clicked. Some example code is below: MainWindow::MainWindo...