c++

CEditBox or CListBox which one is better for big amout of logging data

This always was a big question for me that for a very big amount of logs (like 100,000 line log) which one is better in performance, scrolling,... also consider formatting the text with color is a must. ...

Should screen dimension constants that hold magic numbers be refactored?

I have a few specific places in my code where I use specific pixel dimensions to blit certain things to the screen. Obviously these are placed in well named constants, but I'm worried that it's still kind of vague. Example: This is in a small function's local scope, so I would hope it's obvious that the constant's name applies to what t...

What does "hard coded" mean?

Hi guys. I gotta problem, it's just a lil one. I have like three assignments due tomorrow night but in order to do two of them, I have to be able to access a test.txt document from my IDE. To do that, the file has to be hard coded to my C drive. I have no idea how to do this. Can somebody please help me with this? I would really apprecia...

Sequence points and partial order

A few days back there was a discussion here about whether the expression i = ++i + 1 invokes UB (Undefined Behavior) or not. Finally the conclusion was made that it invokes UB as the value of 'i' is changing more than once between two sequence points. I was involved in a discussion with Johannes Schaub in that same thread. Accor...

Can constructor call another constructor in c++?

class A{ A(int a = 5){ DoSomething(); A(); } A(){...} } Can the first constructor call the second one? ...

How to use a class object in C++ as a function parameter

I am not sure how to have a function that receives a class object as a parameter. Any help? Here is an example below. #include<iostream> void function(class object); //prototype void function(class tempObject) { //do something with object //use or change member variables } Basically I am just confused on how to create a functi...

fread speeds managed unmanaged

Ok, so I'm reading a binary file into a char array I've allocated with malloc. (btw the code here isn't the actual code, I just wrote it on the spot to demonstrate, so any mistakes here are probably not mistakes in the actual program.) This method reads at about 50million bytes per second. main char *buffer = (char*)malloc(file_length_...

C++: compute a number's complement and its number of possible mismatches

I got a bit stuck with my algorithm and I need some help to solve my problem. I think an example would explain better my problem. Assuming: d = 4 (maximum number of allowed bits in a number, 2^4-1=15). m_max = 1 (maximum number of allowed bits mismatches). kappa = (maximum number of elements to find for a given d and m, where m ...

How to mix C++ Qt objects and Qt Jambi objects

Hi, I'm trying to combine some existing Qt code written in C++ with some code written in Java using Qt Jambi, but I'm not quite sure how to do it. I'm basically trying to acieve two things: Pass a QObject from C++ to Java using JNI Pass a Qt Jambi QObject from Java to C++ It looks like I can pass the pointer directly and then wrap i...

Strange error occured while using cmake

Does anyone knows what "The C compiler "cl" is not able to compile a simple test program." means? I am trying to compile Wt using CMake on MSVC 9. The OS is Windows XP. Here is the full log: Check for working C compiler: cl Check for working C compiler: cl -- broken CMake Error at I:/Program Files/CMake 2.8/share/cmake-2.8/Mo...

counting letters in a text file

Can sommebody please tell me what is not right about this code? It compiles and everything great but the output is solid zero's all the way down. So it is not counting the letters. #include <iostream> #include <fstream> #include <string> using namespace std; const char FileName[] = "c:/test.txt"; int main () { string lineBuffer...

Lame operator redefinition error

Sorry it's lame but I can't figure it out: class Address { public: uint32_t addr; uint16_t port; public: Address(); Address(uint32_t addr, uint16_t port); Address(const Address & src); Address& operator=(const Address &src); bool isNull(); friend std::ostream& operator<<(std::ostream& os, const Addre...

CSocket Server get the client IP Address

How can I get the ip address of a client when he tries to connect to the server? I'm using CSocket class. ...

simple wildcard match with std::string

I have std::string with the follwing format std::string s = "some string with @lable" I have to find all instances of '@' and then find the identifier right after the '@' , this ID has a value (in this case 'lable' stored for it in a look up table. I will then replace the @ and the id with the found value. for example suppose t...

calling member function without object error: C++ / (G++) oop

Hi, i was curious to know why the following throws an error in g++ (cannot call member function without object). I suppose a workaround would be to have the B class variable as static variable in A - but i was curious to find out why, when there is an instance of A's child class C created, this still throws an error - many thanks! #inc...

[C++] Why shall I use "using" keyword to access my base class method?

I wrote the code below in order to explain my issue. If I comment the line 11 (with the keyword "using"), the compiler does not compile the file and display this error: invalid conversion from 'char' to 'const char*'. It seems to do not see the method void action(char) of Parent class in Son class. Why the compiler behaves this way? Or h...

linking assembly and c problem

Trying to understand how to link a function that is defined in a struct, the function is in the assembly code, and am trying to call it from c. I think am missing a step cause when I call the function, I get an unresolved external symbol... ;Assembly.asm .686p .mmx .xmm .model flat include Definitions.inc .code ?Initialize@Foo@@SIXPA...

Recursive calls when trying to wrap and override the global operator new.

I have not programmed C++ for a while and encountered a strange behavior when toying with overloaded global operators new and delete. The essence of the problem seems to be that a wrapper build around the default global new and residing in a separate source file nevertheless calls an operator new overloaded in another (and separately c...

Task Execution Framework for VC++?

Hi, Does anyone know of a Java ExecutorService equivlent in VC++ 2008? What I want is a framework which I can pass tasks to fixed size thread pool. The framework should manage the thread pool itself (i.e. creation and destruction of threads). ...

Tile sizing algorithm

I'm making a tile game in c++. Right now when the game loads all the tiles place themselves based on: tilesize -> they are squares so this is width and height tile_count_x tile_count_y I have the following variables: desktop_width desktop_height game_window_width game_window_height tile_count_x tile_count_y Based on these valu...