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?
...
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...
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...
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...
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:
/*
...
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...
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(...
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.
...
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...
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...
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 ...
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...
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 ...
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?
...
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?
...
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...
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.
...
Possible Duplicate:
Is it possible to define enumalpha?
Is there any equivalent of Java Enum.valueOf(string) on C++?
...
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...
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.
...