c++

const member isn't explicitly initialized but compiles

I heard that const members must be explicitly intialized, but the following compiles for me: class someClass { int const x; }; int main() { return 0; } ...

Template instantiation refused with function-local classes

Possible Duplicate: How to use local classes with templates? g++ 4.4 is refusing to compile a call to a template function taking a function-local class as a template parameter. Like so: // Given this: template <typename C> int f(const C& c) { return c.g(); } // This compiles fine: struct C1 { int g() const { return 42...

How does a C/C++ compiler find the definitions of prototypes in header files?

When I declare a function in a header file, and put the definition of that function in some other file, how does the compiler/linker find the definition? Does it systematically search every file in its path for it, or is there a more elegant solution? This has been bugging me for the past few days, and I've been unable to find an explana...

Declaring types and templates with the same name in C++

This is an academic question. In the report for GCC bug 38764, there are the following examples: template < class T > struct A {}; typedef A< float > A; // Accepted by Comeau, but not GCC typedef ::A< float > A; // Accepted by GCC but not Comeau I see why the code may be invalid, but I have trouble with one of the comments: This ...

Split text using strtok without deleting the delim c++

How can I split a text into tokens using strtok without deleting the delim? I want just to split at their place. ...

Passing char array in a function?

Here is my problematic coding: I have to take in 2 player's name. Then when for the next part when the player marker changes the name stored in "currentPlayer" should change too the name stored in either playerOne or playerTwo. It doesn't so how do I fix that? Please solve, I tried to make it a reference variable with the & symbol but I...

Is it safe to replace GCC's system-level C++ runtime with a version from newer GCC?

Linux C++ programs build with GCC link against libgcc_s.so.1 and libstdc++.so.6 libraries, each of which contains multiple ABIs: newer versions contain ABIs from previous version plus new ones. GCC ABI policy document says programs build against older runtime should be able to be run with the new runtime. So, theoretically, older binarie...

Client and server

Hello, I would like to create a connection between two applications. Should I be using Client-Server or is there another way of efficiently communicating between one another? Is there any premade C++ networking client server libraries which are easy to use/reuse and implement? Application #1 <---> (Client) <---> (Server) <---> Applicat...

Help Turning C++ coding into Function

SigTerm said this: "Smells like a bad code. squareOne..squareSix should be probably array. Instead of char constants, enums or ints should be probably used... " How do i do that with this code for the board also if someone could suggest the code I would have to use to get users to enter the row and column for the X and O for the game. v...

Add C file to Visual Studio

I'm using Microsoft Visual Studio 2010. When I add files to my project, they have a .cpp extension. To work with C, I have to manually rename the files to .c. Is there any way to directly add C files, without renaming anything? ...

How are elements stored in containers in .Net?

Hi How are elements stored in containers in .Net? For example, a C++ vector stores in sequential order, while List doesn't. How are they implemented for .Net containers (Array, ArrayList, ...)? Thanks. ...

I have a string "abc=14,22 xyz=33, tdc=48" in a file. How can I separate it into strings and their corresponding values in C++?

I have a string "abc=14,22 xyz=33, tdc=48" in a file. How can I separate it into strings and their corresponding values in C++? like-- abc = 14,22 xyz = 33 tdc = 48 ...

How does this "size of array" template function work?

Possible Duplicates: Can someone explain this template code that gives me the size of an array? Magic arguments in function templates Can someone explain how this code works? I know that the purpose of this code is to get the length of an array, but I don't know how this code works: template<typename T, int size> int GetArr...

SDL / C++: How to make this function short(er)?

I have this: void showNumbers(){ nrBtn1 = TTF_RenderText_Blended( fontnrs, "1", sdlcolors[0] ); nrBtn2 = TTF_RenderText_Blended( fontnrs, "2", sdlcolors[1] ); nrBtn3 = TTF_RenderText_Blended( fontnrs, "3", sdlcolors[2] ); nrBtn4 = TTF_RenderText_Blended( fontnrs, "4", sdlcolors[3] ); nrBtn5 = TTF_RenderText_Blended( ...

Turn code into an Array and Display

How can I turn this into an array? I need a board to show blank spaces and when the user enters it gets filled with a X or an O by another function. The current board works I would like to make it into a array[3][3] and display the contents of the array. void showboard(char &squareOne, char &squareTwo, char &squareThree, char &squareFou...

This application has requested the RunTime.....??

I developed C++ code on Windows Server 2008. I was running that exe on Windows Xp. I am getting the Runtime Error C++ "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information". Could you please tell me the reason why I am getting this error. ...

Voice recognition : voice driven control

Hi all, Few days ago i asked for a project idea for my B.tech Final year project. Unfortunately couldn't got any cool idea. Now I have got an idea which really pleases me and motivates me. I want to ask to intelligent guys out there is following thing is feasible in 5 months: The Project idea is : "A Voice Driven Controlling of The...

Problem printing out linked-list

I am trying to create my own datatype that is like a vector or an array. I am having troubles with my print function; When I go to print the list, it only prints the last item in the list. // LinkedListClass.cpp : Defines the entry point for the console application. #include "stdafx.h" #include <iostream> class Node { public: int va...

Confusion over Win32 CreateProcess

I am confused by the first 2 params, module and command-line. I find unless I populate both it doesn't work right, and it seems the documentation says otherwise. I want to call "testApp.exe param1=123" The only way I found that works is: CreateProcess("testApp.exe","testApp.exe param1=123",... I thought either of these should work, ...

Accessing std::list from one or more thread

Hi All I need to access(only read) the data in std::list from one or more threads running in my application. This list will be created only once at time of booting an application and after all this list will be reading from muliple threads...say I will be doing this for (std::list <iterator>iii=list->begin();ii!=list->end();ii++) ...