c++

Array decay to pointers in templates

Please consider this code: template<typename T> void f(T x) { std::cout << sizeof(T); } int array[27]; f(array); f<typeof(array)>(array); This will print 8 (or 4) 108 In the first case, the array obviously decays to a pointer and T becomes int*. In the second case, T is forced to int[27]. Is the order of decay/substitution imp...

Uniform initialization in C++0x, when to use () instead of {}?

Hi, Is there a rule of thumb to decide when to use the old syntax () instead of the new syntax {}? To initialize a struct: struct myclass { myclass(int px, int py) : x(px), y(py) {} private: int x, y; }; ... myclass object{0, 0}; Now in the case of a vector for example, it has many constructors. Whenever I do the following: ...

GCC Compiler Warning: extended initializer lists only available with c++0x

Using this member initialization... StatsScreen::StatsScreen( GameState::State level ) : m_Level( level ) { ...// } I get the following warning... extended initializer lists only available with -std=c++0x or -std=gnu++0x Any information regarding this warning? Edit: Warning went away after I removed one of the member that w...

In .cpp file, defining methods with "class Foo { void method() {} };" instead of "void Foo::method() {}"?

When you have inline definitions of functions in the header file, and you want to move the the function definition bodies out of the header and into a .cpp file, you can't just cut-and-paste the functions as they were defined in the header; you have to convert the syntax from this: class Foo { void method1() { definition(); } void metho...

Reading Superblock into a C Structure

I have a disk image which contains a standard image using fuse. The Superblock contains the following, and I have a function read_superblock(*buf) that returns the following raw data: Bytes 0-3: Magic Number (0xC0000112) 4-7: Block Size (1024) 8-11: Total file system size (in blocks) 12-15: FAT length (in blocks) 16-...

What common application types are created with Visual C++?

C# and VB .net (higher level languages) tend to be good for n-tier business applications and such. I find C++ a very interesting language and would like to spend more time developing in it. What kinds of applications are better suited to C++ applications? Are many windows forms apps (for example) created using C++? ...

Native Makefile alternative for windows

What is a good alternative to Makefile on windows? I'm compiling a collection of c++ files (.cpp's and .h's) using cl.exe. I'd rather not use Makefile, as I want to minimise the amount of 3rd party utilities people will need to build my application. Drew J. Sonne. ...

Problem with formatting output c++

I am working on a binary search tree.. I am having a problem getting the nodes to left align on output. I am printing array order, pre-order,inorder,postorder... Array order format is left aligned like i want it to be.. Im basically using the same code( setw and left; in the same order) as array order as i am with preo order, and the res...

How to declare a static variable but not define it

Some times we need to pre-declare a static variable and then use it. But the variable name of this declaration may be wrong, and the compiler can not detect it, oops! Example: /* lots of codes */ static some_type some_name; /* pre-declaration */ /* but it may define "some_name" */ /* use some_name */ /* lot...

Pthreads problem and a few questions...

#include<pthread.h> #include<stdio.h> #include<stdlib.h> #include<time.h> #define NUM_THREADS 8 char *messages[NUM_THREADS]; struct thread_data { int thread_id; int sum; char *message; }; struct thread_data thread_data_array[NUM_THREADS]; void *PrintHello(void *threadarg) { int taskid, sum; char *hello_msg; struct ...

Need help with Binary Search Tree in C++

I'm trying to make a BST and need to print it inorder, postorder, and preorder The thing am not sure about is how to create this tree in my main() function. struct Tree_Node { Tree_Node *right; Tree_Node *left; int info; }; class bTree { private: Tree_Node *root; public: bTree(); void bTree::Insert(Tree_Node*& ...

Need sample problems for hands-on

I have been working with C++ for a few years now and have got good theoretical knowledge on the matter (I think). However I've been missing involvement in good projects, sort of projects that really gets one going on the technologies. So I intend to work on my own to get some good grip on C++ and related technologies. 'Have started with ...

Compile 64 bit app with VC Express 2010?

Is there a simple way to compile a 64 bit app with Visual C++ Express 2010? What configurations, if any, are necessary? ...

is it necessary to learn java for contributing to an open source project?

I am more into c/c++. But many of my seniors here in college ask me to learn java if I want to contribute to an open source project.. I m in dilemma. what to do?? Can't we do a design project in c/c++?? ...

Simulate fullscreen

Hi, I've seen an application that simulates a fullscreen application by removing the title bar and the window borders. I've done some research and found getWindowLongPtr() for that. Now my question: How can I find and identify the application and get the appropriate window handle? How can I distinguish multiple instances of the applica...

Create Wi Fi network by C++ or C# and Windows API

I want to create Wi-Fi network.The Server must get dynamically parameters to configure it's Wi-Fi adapter as access point and clients must get same parameters to connect to the server via Wi-Fi. How can i Create Wi Fi network by C++ or C# and Windows API,may be Native Wi Fi API on that server with Wi-Fi Adapter? The way that server get...

Which C++ does Visual Studio 2008 (or later) use?

Hello, I find C++ is very controversial language in microsoft world. By default we have ISO C++ and then microsoft has Managed C++ and now C++ CLI. I just know standard (ISO) C++. I don't know microsoft's version of C++. I'm confused about interpretation of any c++ code by visual studio 2008 (or later). Thats why I'm using gnu tools f...

Generic VC++ vs g++ query

I have trouble understanding the compilers. The following code does work in UNIX under g++, but under VC++ it would not even compile. Anyone can provide valid reasons why? #include <stdio.h> #include <iostream> #include <string.h> using namespace std; int main() { string tmp_nw_msg, crc_chksum, buffer; cout << "Enter the str...

C++: Loading an EXE as a DLL, local vftable problem

Ok, so this one is abit long to explain so bare with me.. I have an exe named test.exe which is usually used as a stand alone application. I want to use this exe as a module (a dll) inside another application, app.exe. The code in test.exe does something really simple like: void doTest() { MyClass *inst = new MyClass(); inst->...

Using (void*) as a type of an identifier

In my program, I have objects (of the same class) that must all have a unique identifier. For simplicity and performance, I chose to use the address of the object as identifier. And to keep the types simple, I use (void*) as a type for this identifier. In the end I have code like this: class MyClass { public: typedef void* identity_t;...