c++

Why can't I compile this non-CLR program in VC++ 2008? How to do it?

Why can't I compile/run this non-CLR program in VC++ 2008? How to do it? MyProgram.cpp #include <iostream> namespace System { public class Console { public: static void WriteLine(char str[]) { std::cout<<str; } }; } int main() { System::Console::WriteLine("This a non-CLR p...

using static_cast with boost::bind

I want to transform a vector of type T to a vectorof type K. I tried this, but it doesn't work: transform(vec.rbegin(),vec.rend(),vecNew.begin(),boost::bind(static_cast<K>(),_1)); I get the error: "expected primary-expression before ‘)’ token". What am I doing wrong? ...

Building a boost application using a Makefile and MinGW (Undefined references)

Okay so I have the following makefile CC = g++ #CFLAGS = -g -Wall CFLAGS = -g LDFLAGS = -lm #client : shared.lib #server : shared.lib shared : src/shared/opcode.h $(CC) $(CFLAGS) -I./src/ -I./lib/boost/ -L./lib/boost/stage/lib/ -L./lib/win_sdk/ \ -D_WIN32_WINNT=0x0501 \ -lWS2_32 \ -lboost_system-mgw34-mt-1_43 \ -lboos...

char printable program

i have program which prints all char from char_min to char_max here is code #include <limits.h> #include <stdio.h> #include <stdlib.h> int main(){ char c; c=CHAR_MIN; while(c!=CHAR_MAX){ printf("d\n",c); c=c+1; } return 0; } but it prints only all d why?ouput is like this d d d d d d d...

delete function in cpp

hi, I saw an example of using the function: delete in cpp and I didn't completely understand it. the code is: class Name { const char* s; //... }; class Table { Name* p; size_t sz; public: Table(size_t s = 15){p = new Name[sz = s]; } ~Table { delete[] p; } }; what is the exact action of the command: de...

Using D3DImage in C++ .net

Hi, I think this is an easy question, sorry I am not really familiar with C++. I am using D3DImage in C++.Net project which is using it's SetBackBuffer method, and I am also using DX Surface. I don't know how to convert IDirect3DSurface9 to IntPtr as parameter in SetBackBuffer method. Anyone knows? please help. ...

Why isn't the vtable created?

I'm making a memory patcher for a game but when compiling it with only a single patch implemented, no vtable was created (Using mingw). Could someone tell me what is the problem and how I can fix it? a_patch.cpp (Compile this) #include "a_patch.h" void a_patch::init_patch() { /* example initilisation */ init_var(); vector...

a compiler generated default constructor in c++

Hi, declaring a struct Table: struct Tables { int i; int vi[10]; Table t1; Table vt[10]; }; Tables tt; assuming that a user-deault contructor is defined for Table. here tt.t1 will be initialized using the default contructor for Table, as well as each element in tt.vt. On the other hand tt.i and tt.vi are...

Where can I find C/C++ Linux API's for robotics?

Specifically for sending commands and receiving sensor data. ...

requirement for a function to be inline in c++

hi, what are the requirement for a function so it could be executed inline in c++? is there a case that a function can't be inline? or any function can be inline and it is the responsibility of the programmer to decide how to define the function, based on run time and compilation-time considerations? ...

what will be the addressing mode in assembly code generated by the compiler here ?

Suppose we've got two integer and character variables: int adad=12345; char character; Assuming we're discussing a platform in which, length of an integer variable is longer than or equal to three bytes, I want to access third byte of this integer and put it in the character variable, with that said I'd write it like this: character=...

C++: Question about copy constructors

Hi, I have a class where I use this to initialize a void* pointer. But the problem is, when I pass an instance of that class by value, the pointer will not change to the new address on the stack. So, I thought to override the copy constructor to reassign the pointer with the new address of this. But I need variables to call the super-cl...

Returning reference from a function and modifying it

#include<iostream> int& f(){ static int x = 0; x++; return x; } int main(){ f() += 1; //A f() = f() + 1; //B std::cout << f(); } The above code outputs 6 on gcc and 5 on MSVC. Now when I modify A and B to f()=f() I get 5 on both compilers. What is the big deal here? Is the behavior undefined. If yes , why? ...

C++/CLI or plain C++ with regards to graphics / rendering

I come from a .NET background and will be going into the field of rendering / graphics using OpenGL/DirectX. For this purpose C++ will be my language of choice to interact with these rendering frameworks. As I understand it Visual C++ allows native support for CLI which is an extension to C++ that allows the application to benefit from ...

LINK : fatal error LNK1104: cannot open file 'libcollada14dom21.lib'

I have hot this error at the linker: LINK : fatal error LNK1104: cannot open file 'libcollada14dom21.lib' I dunno why, libcollada14dom21.lib is in VSDIR/VC/lib. ...

Linking in several C object files that contain functions with equivalent signature

Lets say I have a C++ program and I want to call functions from a C object file in it. The constraint is that I'm not allowed to make any changes to the C source files. In this case I would include the C header as extern "C" in my C++ file, call the function, compile the C object using gcc -c, and pass the result to g++ along with the a...

Filling std vector

Hello, I can't understand why does vector empty after it's filling. The code is: bool fillArray (vector<int> &array) { string temp; getline(cin, temp); if (temp == "-1") return false else return true; int res = atoi(temp.c_str()); array.push_back(res); } void showArray(const vector<int>...

How does initialization to a value compare in performance to assignment?

Hi, I read that for user-defined types, postponing the defintion of a variable until a suitable initializer is available can lead to better performance. why? ...

Audio generation and analysis framework in C++

Hello, I am looking for a C++ framework that can synthesise audio and also has the ability to analyse audio input for its frequencies. What I am trying to do is create a digital transmission algorithm that can transmit data and text via audio. It should be possible to create an audiostream with different frequencies and phasing at one ...

Video Stabilization with OpenCV

I have a video feed which is taken with a moving camera and contains moving objects. I would like to stabilize the video, so that all stationary objects will remain stationary in the video feed. How can I do this with OpenCV? ie. For example, if I have two images prev_frame and next_frame, how do I transform next_frame so the video came...