c++

Linking Lua with Visual Studio 2010

We use Lua (www.lua.org) script to let users to customize our server software written in C++. At the moment we are porting the 32 bits Windows version of our project to Visual Studio 2010. Once everything works fine with VS 2008, we thought that we would have no problem on upgrade process. Unfortunately whenever we tried to link the lu...

How to call a C++ DLL from VB6 without going through COM?

OK, so I have a C++ project that compiles to a DLL file. I am able to reference this file in C# and see/use all of the objects and functions within the DLL file. What I need to do is to reference those objects and function through VB6. The C++ code has nothing in it that looks like it's creating a DLL. There are no '__declspec(dllexport...

What am I doing wrong that I can't render an image/texture properly in OpenGL?

I'm trying to render an image to the window. Super simple (or so I thought). No matter what I do, I always get this purple square. Some tidbits of my code: // load image from file, called one time on load: glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); glEnable(GL_DEPTH_TEST); RgbImage theTexMap( filename ); glGenTexture...

Binary trees in C++ using references

I wish to implement a binary tree using references instead of using pointers (which is generally what you tend to find in every book and every website on the internet). I tried the following code: class tree_node { private: tree_node& left; tree_node& right; data_type data; public: void set_left(tree_node&); // ... o...

vector template conflicting declaration

I'm trying to implement a function that allows me to make a call like this // vec5 is a vector of tuples in my case // some code that to declare and fill vec5 columnViewOfTuple<0>(vec5); I implemented such function as follows template<int N> struct myfunction { template<typename T, typename R> std::vector<R> opera...

stack and queue with a link list

I have an assignment where i need to implement a stack and a queue with a link list. How would i go about implementing it? would i use a circular link list and i can add to the head and tail? I wasnt looking for any code handouts and i dont think its fair that i got minus two points for asking a generalized question. This is how i think ...

Shouldn't be these warnings with g++ -Wall?

I was just curious if the following code should result in warning or not by g++ compiler: // Snip #1 bool x = 0; x++; // Snip #2 switch (x) { default: printf("hi\n"); } The problem is such statements exist in a legacy code i work upon :-|, I guess there should be some warnings for these? I have g++-4.4.3c ...

C++ POST Form Data.

I was able to do this in perl, so now I'm trying to give it a shot in c++. My goal is to submit a md5 hash to http://md5crack.com/crackmd5.php and receive the plaintext back. Correct me if I'm wrong, but to do this you need to send the header information. I'm not exactly sure how to go about this so I broke it up into separate string var...

Friend classes across different namespaces. Is that possible

Hello all, I'm having problems trying to use the friend feature of C++. I have these interfaces: #pragma once #include "Mesh3D.h" #include <string> namespace tools{ namespace sysInput{ class CGeometryManager3D { public: bool loadFromFile(render::CMesh3D& mesh, std::string filename); C...

C++ inheritance problem

I am trying to implement a leftist tree using heaps as a base class. The following is the contents of heap.h: template <class T> class heap { public: virtual void init(T*) = 0; virtual void insert(T*) = 0; virtual T delete_min() = 0; }; The following is the contents of leftist.cpp: #include "heap.h" template <class T> c...

Change the executable name in Eclipse for C++

I've created a C++ project in Eclipse and currently it builds an executable called file.exe but I want to change this to "file". How do I do this? Thanks. ...

Convert a double to fixed decimal point in C++

I have a double variable in C++ and want to print it out to the screen as a fixed decimal point number. Basically I want to know how to write a function that takes a double and a number of decimal places and prints out the number to that number of decimal places, zero padding if necessary. For example: convert(1.235, 2) would print ...

c++ calculate all the angles between two angles

I have a set of previously defined float values(a set of angles) I need a function which takes two angles as input and returns all the angles between them. The user first enters a set of angles in float and then the user can enter any two angles(my program should return all the angles between these values) For example 30,310(return all ...

Where is the 'iPac' Custom Resource Builder?

I was looking for a method of implementing a custom resource file system for a while now (googling "c++ custom resource file" doesn't give much of anything) and I stumbled across a book online describing EXACTLY what I was looking for down to every last detail. It talks in depth about the iPac system, but I have not been able to find an...

C++ equivalent to Java's System.arraycopy

I'm a Java programmer and have recently needed to start coding in C++. I'm trying to port some Java code of mine that makes heavy use of the System.arraycopy method and want to know if there is an equivalent in C++. Basically I want to have n byte arrays and combine them into one big array. Each of the initial arrays can be of variabl...

Error message: start in crt1.10.6.o ld: symbol(s) not found collect2: ld returned 1 exit status

Hi, I'm a beginner in C++ programming and I keep getting this error message. I have no idea what it means...I'm using XCode for Macs version 3.2.4, 64-bit. Could someone tell me what this means? the error message is: start in crt1.10.6.o ld: symbol(s) not found collect2: ld returned 1 exit status If you need a look at my program, he...

boost::thread assertion error

I'm trying to create a simple test program using boost::thread, but I get a runtime assertion error. Here is the code: #include <iostream> #include <boost/thread.hpp> void hello (void) { std::cout << "Hello, world!" << std::endl; } int main (void) { boost::thread t(&hello); t.join(); // Fails even without this line } T...

Test for void pointer in C++ before deleting

I have an array in C++: Player ** playerArray; which is initialized in the constructor of the class it is in. In the destructor I have: delete playerArray; except when testing the program through Valgrind it says that there are some calls to delete to a void pointer: operator delete(void*) I want to test whether the playerArr...

How do I check if a directory is a file or folder?

Okay, so I'm using mingW, and the direct struct has no variables named d_type or stat, d_stat, or dd_stat. I need to know how I can use my direct struct to figure out if what I have is a file or folder. Here is my code. #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> #include <errno.h> #include <vector> #include <string...

Function passing arguments in reverse

Here is my function: void abc(char *def, unsigned int w, unsigned int x, unsigned int y, unsigned int z) { printf("val 1 : %d\n", w); printf("val 2 : %d\n", x); printf("val 3 : %d\n", y); printf("val 4 : %d\n", z); } and here is where I call this function: unsigned int exp[4] = { 1, 2, 3, 4 }; unsigned short count = 0; a...