c++

How to apply compiler rules when resource.h or icon.ico should be included in the exe?

I am using #define and #ifndef to strip down the exe size, i noticed the resource.h and icon.ico files eat a lot of space, so i would like to not include those in my exe at all. How do i add rule for this that obeys my #define commands ? I could edit the resource.h, but every time i change it, it would get overwritten by Visual Studio. ...

How to make my private class visible for STD containers?

This is the code: #include <map> class Hidden { private: friend class Visible; Hidden(); { /* nothing */ } }; class Visible { public: void f() { std::map<int, Hidden> m; m[1] = Hidden(); // compilation error, class Hidden is private } }; The code doesn't compile because the constructor of class Hidden is private for cl...

Switch structure in C++ not working

#include<iostream> #include<stdio.h> using namespace std; void student_array(); void query(); void show_arr(); void student_entry(); struct student { char name[80]; char f_name[80]; char the_class[3]; char grade[2]; }; student std_arr[10]; char action; int count; int main() { cout<<"add 1st student"<<endl; st...

OpenGl VBO technicalities in C++

I'm a little confused as to the proper usage of VBOs in an OpenGL program. I want to create a terrain paging algorithm, using a map called from a 4096x4096 greyscale heightmap as the "whole" map. From what I've read, each vertex stored in the VBO will take up 64 bytes. The problem I have is that most sources state that a single VBO sh...

Unable to play uri using gst_element_make_from_uri in gstreamer

Hi I need to stream rtsp / http stream and when i create an element source using source = gst_element_make_from_uri(); it doesn't work. Has anybody used gstreamer for streaming rtsp / http streams. Please help.. I am attaching the code snippet also source = gst_element_make_from_uri (GST_URI_SRC,"http://76.73.90.27:80/" ,NULL); dec...

Confusing std::map insert behavior

I get some strange behavior when inserting values into a map: I always insert at the end of the map, but sometimes the entries get out of order. If I do a straight forward test, then I get no problems- the numbers are correctly ordered: map<int,int> testMap; for(int i = 0; i < 100; ++i) { // everything is ordered correctly here ...

question on string iterators

I have following code #include <iostream> #include <string> #include <algorithm> using namespace std; int main(){ string d="georgia is nice country": string::iterator my; for (my=d.begin();my!=d.end();my++) { cout<<*my<<endl; } return 0; } but it causes a compiler error saying "my is undefined". What is wrong? ...

Question about strcmp

For example we have two strings: string s = "cat"; string s1 = "dog"; Is it correct to write the following method? int a = strcmp(s, s1); Or what will be correct form? ...

Differences between build and make?

Recently, I downloaded a copy of mysql source code from their source tree. but i am not sure how can i compile the code. i do not quite understand the different processes involved in c++ software building. after i have built the code, how can i install it? or do i need to make? or how do i even know if the 'build' is successful, it print...

any building tool can automatically understand file dependencies in C++ project?

I have a project with 50+ .h files and 50+ .cpp files. I'm using make to build a project, which looks something like this (it's just a piece of an entire file): HEADERS := $(shell find $(INCLUDE) -name "*.h") %.obj: %.cpp $(HEADERS) $(CPP) $(CPPFLAGS) -fPIC -o $@ -g -c $< When I'm making changes to one .h file, the whole project h...

what's the reason of my code? a unhandled exception

debug src: http://www.cppblog.com/Files/mymsdn/cvector-bug-vs2008-201007101651.zip Hey all, I have repair my code, thanks yours help! You can download the correct version of my code. src: http://www.cppblog.com/Files/mymsdn/cvector-vs2008-20100710.rar I am trying to write a C language version of vector. I use the void ** a the pRo...

Redirect a file stream into memory stream

Hey, I do have a program (call it "a.exe" for example) which reads its config from several files. can I write another program to redirect all file accesses of "a.exe" to another stream (console for example)? I don't have the code of "a.exe" but if I get the source code of a.exe, obviously I can change all the file accesses. but is ther...

[c/c++] set variable to cmd.exe

Greeting earthmen, Here is my question: How can I create a program which sets variable to current session of cmd.exe e.g. c:\> set myvar Environment variable myvar not defined c:\>myexe.exe c:>set myvar myvar=myvalue The only similar topic that I've found is this - http://stackoverflow.com/questions/774047/how-can-i-change-windows...

C++0x Lambda overhead

Is there any overhead associated with using lambda expressions in C++0x (under VS2010)? I know that using function objects incurs overhead, but I'm referring to expressions that are passed to STL algorithms, for example. Does the compiler optimize the expression, eliminating what seems to appear like a function call? I started to really...

Writing cross-platforms application with a complex GUI

Hi! I'd like develop an application with a complex GUI (combobox with animation, charts with spline, transparent layers, ...). I've good experience with C# 2.0 and I'm studying WPF, but unfortunately I read that there is no plan to port WPF on Mono. I was thinking about creating my custom GUI control using OpenGL (with OpenTK)... But I...

temporary object c++?

what is a temporary object? how to use it? how to use with copy constructors and destructors? ...

C++, console Application, reading files from directory

I have a directory and I want to read all the text files in it using C++ and having windows OS also using console application I don't know the files' names or their number thanks in advance ...

Checking whether two numbers are permutation of each other?

Given two numbers a, b such that 1 <= a , b <= 10000000000 (10^10). My problem is to check whether the digits in them are permutation of each other or not. What is the fastest way of doing it? I was thinks of using hashing but unable to find any suitable hash function. Any suggestions? For e.g - 123 is a valid permutation of 312 A...

Memory deallocation in c++ issue (Visual Studio 2010)

Hi, I am trying to learn C++, in the process I tried to write a function that gets two char pointers and concatenate the second one to the first one (I know there is strcat for this). But - what I want to accomplish is to modify the first parameter pointer so it will point to the result. for this reason I used a reference to pointer in t...

C++ - Detours WinSock Hooking -> HELP

Hello I need to hook over the Send and Recv Function of Firefox but it doesn't work... I tried some things but nothing worked! (My c++ isn't as well as i wish ;) and so it's more diffcult for me...) ...