c++

How do i get the screen to pause?

Possible Duplicate: How to stop C++ console application from exiting immediately? So im learning c++ and i was given this example and i wanted to run it. But i cannot get it to stay up, unless i change it. How do i get Microsoft visual 2010 to keep up the screen when it gets to the end of the program after I release it? #incl...

Learning to compile in xcode

I have started using c++ extensively in school and now my programs are getting to the point where have more than 1 file (i.e. header, driver, implementation file). I don't know enough about software development to understand or get a grasp of how to setup the build process by looking at apple's guides. Could someone walk me through how t...

daynamic 2d array in c++ and memory leaks

Hi guys, i wrote this code, it runs ok, but when i check it under Valgrind it catches 2 problems, since i can not interpret valgrind's messages i will appreciate if anyone explain me more and tell me where is the problem!!! here is the code: #include <iostream> #define width 70000 #define height 10000 using namespace std; int main...

C++ Beginner Delete Question

Hi all, This is my first year learning C++ so bear with me. I am attempting to dynamically allocate memory to the heap and then delete the allocated memory. Below is the code that is giving me a hard time: // String.cpp #include "String.h" String::String() {} String::String(char* source) { this->Size = this->GetSize(source); this->...

Double Linked List Insertion Sorting Bug

Hello, I have implemented an insertion sort in a double link list (highest to lowest) from a file of 10,000 ints, and output to file in reverse order. To my knowledge I have implemented such a program, however I noticed in the ouput file, a single number is out of place. Every other number is in correct order. The number out of pla...

Convert "this" to a reference-to-pointer

Just stumbled onto this problem. (title says it all) Let's say I have a struct struct Foo { void bar () { do_baz(this); } /* See edit below void do_baz(Foo*& pFoo) { pFoo->p_sub_foo = new Foo; // for example } */ Foo* p_sub_foo; } GCC tells me that temp.cpp: In member function ‘void Foo::ba...

Can I get the amount of time for which a key is pressed on a keyboard

Dear all, I am working on a project in which I have to develop bio-passwords based on user's keystroke style. Suppose a user types a password for 20 times, his keystrokes are recorded, like holdtime : time for which a particular key is pressed. digraph time : time it takes to press a different key. suppose a user types a password ...

C++ preprocessor #define-ing a keyword. Is it standards conforming?

Help settle the debate that's going on in the comments at this question about bool and 1: Can a standards-conforming C++ preprocessor allow one to use #define to redefine a language keyword? If so, must a standards-conforming C++ preprocessor allow this? If a C++ program redefines a language keyword, can that program itself be standard...

Unresolved external symbol error in c++

I am trying to do a simple hw problem involving namespace, static data members and functions. I am getting an unresolved external symbol error Error 1 error LNK2001: unresolved external symbol "private: static double JWong::SavingsAccount::annualInterestRate" (?annualInterestRate@SavingsAccount@JWong@@0NA) SavingsAccount.obj S...

the "new" operator in c++, pointer question

Dumb question, but whenever you call new, do you always have a pointer? SomeClass *person = new SomeClass(); And is that because you need a pointer to point to that new space of memory that was allocated for the SomeClass variable person? Thanks! ...

how to make a name from random numbers?

my program makes a random name that could have a-z this code makes a 16 char name but :( my code wont make the name and idk why :( can anyone show me what's wrong with this? char name[16]; void make_random_name() { byte loop = -1; for(;;) { loop++; srand((unsigned)time(0)); int random_integer; random_...

What is the proper way to declare a specialization of a template for another template type?

The usual definition for a specialization of a template function is something like this: class Foo { [...] }; namespace std { template<> void swap(Foo& left, Foo& right) { [...] } } // namespace std But how do you properly define the specialization when the type it's specialized on is itself a template? Here's...

C++ Translation Phase Confusion

Can someone explain why the following doesn't work? int main() // Tried on several recent C++ '03 compilers. { #define FOO L const wchar_t* const foo = FOO"bar"; // Will error out with something like: "identifier 'L' is undefined." #undef FOO } I thought that preprocessing was done in an earlier translation phase than string lit...

using declarations in main (C++)

Although you wouldn't want to do this, if you have a namespace COMPANY, and a class in that namespace SOMECLASS. Why is it that in the .cpp file, you might define the functions as COMPANY::SOMECLASS::someFunction() {} But in main, I get errors for doing: int main() { COMPANY::SOMECLASS::someFunction(); } but instead you declare ...

Creating a Transparent Bitmap with GDI?

I want to implement a layering system in my application and was thinking of creating a bunch of transparent bitmaps, adding content to them then blitting them on top of each other, how can this be done without setting each pixel to (0,0,0,0). I'm using Pure win32, not MFC, thanks. ...

FreeLibrary vs implicit unloading DLL

I have implemented a DLL including DllMain() entry function:- BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { case DLL_PROCESS_ATTACH: /* here im doing file memory mapped through CreateFileMapping() API and using it through MapViewOfFile() API storing some data struct...

C++ "delayed" template argument

hello. Is there direct way to do the following: template < class > struct f {}; template < class F > void function() { F<int>(); //for example // ? F template <int>(); } function < f >(); I have workaround by using extra class around template struct. I am wondering if it's possible to do so directly. Thanks ...

g++: how to specify preference of library path?

I'm compiling a c++ program using g++ and ld. I have a .so library I want to be used during linking. However, a library of the same name exists in /usr/local/lib, and ld is choosing that library over the one I'm directly specifying. How can I fix this? For the examples below, my library file is /my/dir/libfoo.so.0. Things I've tried tha...

Free Charting Library for Visual C++ 2008

Hello, Can anybody suggest free charting libraries for Visual C++ 2008 Windows Forms Application. ...

Makefile can not find boost libraries installed by macports

I just installed boost 1.42.0 from macports using sudo port install boost. Everything worked fine. Now I have a project that I'm trying to build using a makefile. Everything builds fine until it comes to the file that needs the boost library. It says: src/graph.h:20:42: error: boost/graph/adjacency_list.hpp: No such file or directo...