c++

What all does a compiler add to an empty class declaration?

Suppose, I write class A { }; compiler should provide (as and when needed) a constructor a destructor a copy constructor = operator Is this all what the compiler provides? Are there any additions or deletions to this list? ...

Inheritance - initialization problem

I have a c++ class derived from a base class in a framework. The derived class doesn't have any data members because I need it to be freely convertible into a base class and back - the framework is responsible for loading and saving the objects and I can't change it. My derived class just has functions for accessing the data. But the...

Strange error that I've never encounter in c++ before, anyone know what it means?

Hi, I won't post any code, because there is too much that could be relevant. But When I run my program it prints Internal Bad Op Name! : Success Anybody even know what that means? I'm using g++ to compile my code and nowhere in my code do I cout anything even remotely close to something like that. I don't know where it's coming fr...

How to read the screen pixels?

I want to read a rectangular area, or whole screen pixels. As if screenshot button was pressed. How i do this? Edit: Working code: void CaptureScreen(char *filename) { int nScreenWidth = GetSystemMetrics(SM_CXSCREEN); int nScreenHeight = GetSystemMetrics(SM_CYSCREEN); HWND hDesktopWnd = GetDesktopWindow(); HDC hDesktop...

Another C++ question, delete not working?

New to c++, and am having a problem with delete and destructor (I am sure i am making a stupid mistake here, but haven't been able to figure it out as of yet). When i step through into the destructor, and attepmt to call delete on a pointer, the message shows up "Cannot access memory at address some address." The relevant code is: /* ...

returning aligned memory with new?

I currently allocate my memory for arrays using the MS specific mm_malloc. I align the memory, as I'm doing some heavy duty math and the vectorization takes advantage of the alignment. I was wondering if anyone knows how to overload the new operator to do the same thing, as I feel dirty malloc'ing everywhere (and would eventually like to...

How to treat Base* pointer as Derived<T>* pointer?

I would like to store pointers to a Base class in a vector, but then use them as function arguments where they act as a specific class, see here: #include <iostream> #include <vector> class Base {}; template<class T> class Derived : public Base {}; void Foo(Derived<int>* d) { std::cerr << "Processing int" << std::endl; } void Foo(...

How to compile different extension files as C++ in Visual Studio C++ 2010?

In my Visual Studio 2010 project I have files with .mm file extension, that need to be compiled as normal C++ files. Is there a way to make a build rule for new extensions or something like that? In VS 2008 there were options for that, but they are gone in 2010. ...

Finding all the shortest paths between two nodes in unweighted directed graphs using BFS algorithm

Hi All, I am working on a problem that I need to find all the shortest path between two nodes in a given directed unweighted graph. I have used BFS algorithm to do the job, but unfortunately I can only print one shortest path not all of them, for example if they are 4 paths having lenght 3, my algorithm only prints the first one but I w...

Copy Constructors and calling functions

Hello, I'm trying to call an accessor function in a copy constructor but it's not working. Here's an example of my problem: A.h class A { public: //Constructor A(int d); //Copy Constructor A(const A &rhs); //accessor for data int getData(); //mutator for data void setData(int d); private: int d...

C++ enumeration

Hi,my question is about enumeration,my codes are : #include<iostream> using namespace std; int main() { enum bolumler {programcilik,donanim,muhasebe,motor,buro} bolum; bolum = donanim; cout << bolum << endl; bolum += 2; // bolum=motor cout << bolum; return 0; } The output should be 1 3 but according to these ...

C++ interpreter conceptual problem

I've built an interpreter in C++ for a language created by me. One main problem in the design was that I had two different types in the language: number and string. So I have to pass around a struct like: class myInterpreterValue { myInterpreterType type; int intValue; string strValue; } Objects of this class are passed around mil...

Declaring pointers; asterisk on the left or right of the space between the type and name?

Possible Duplicates: What makes more sense - char* string or char *string? Whats your preferred pointer declaration style, and why? I've seen mixed versions of this in a lot of code. (This applies to C and C++, by the way.) People seem to declare pointers in one of two ways, and I have no idea which one is correct, of if it ...

How to read CD audio data in Windows?

What is the Microsoft-approved way to extract the raw audio data from an audio CD? I'm hoping to do this with C++ or C. It's ironic because in XP/Vista/7, there is the IMAPI (Image Mastering API) for writing data, but not for reading it. Is there a set of API functions for this? Or do I need to send SCSI commands? ...

C++, LHS state after exception is thrown

hi. I am learning C++ exceptions and I would like some clarification of the scenario: T function() throw(std::exception); ... T t = value; try { t = function(); } catch (...) {} if the exception is thrown, what is the state of variable t? unchanged or undefined? ...

C++ trouble with pointers to objects

I have a class with a vector of pointers to objects. I've introduced some elements on this vector, and on my main file I've managed to print them and add others with no problems. Now I'm trying to remove an element from that vector and check to see if it's not NULL but it is not working. I'm filling it with on class Test: Other *a = ne...

(C++) Can you add a direct link into a C++ program with out a GUI?

Hello, I was wondering if you can add a link to a website in a C++ program running in the CMD Prompt type window (No GUI) If it's possible can some one please give me a few examples? Thanks. ...

C++ equivalent of Java Enum.valueOf()

Possible Duplicate: Is it possible to define enumalpha? Is there any equivalent of Java Enum.valueOf(string) on C++? ...

Unresolved External symbol

Hello, I am getting a linking error, and I'm not sure what its referring to. Here is the error 1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall BinaryHeap,class std::allocator > >,class Comp,class std::allocator > > >::insert(class Item,class std::allocator > > const &)" (?insert@?$BinaryHeap@V?$Ite...

C++ Function arguments validation (pointer vs. reference arguments)

Possible Duplicate: When pass-by-pointer is preferred to pass-by-reference in C++? Hello everyone, What do you consider a better programming practice: passing objects as pointers or references to functions. What do you do for input validation? Thanks. ...