In writing a copy constructor for a class that holds a pointer to dynamically allocated memory, I have a question.
How can I specify that I want the value of the pointer of the copied from object to be copied to the pointer of the copied to object. Obviously something like this doesn't work...
*foo = *bar.foo;
because, the bar object...
I have written some C++ code that generates a std::vector.
I also have a python script that manipulates some data that, for now, I am declaring like this (below).
import numpy
x = numpy.random.randn(1000)
y = numpy.random.randn(1000)
I can run the script fine. From my C++ code:
using namespace boost::python;
try{
...
What is the best way to draw things in the Console Window on the Win 32 platform using C++?
I know that you can draw simple art using symbols but is there a way of doing something more complex like circles or even bitmaps?
...
I am trying to make my file parsing more robust. Using an ifstream, how can I ensure seekg keeps me in a valid position within the file?
This does not work:
while(m_File.good() && m_File.peek() != EOF)
{ ...a seekg operation moves file position past end of file... }
I assume the current iterator has been pushed way past the end iter...
I have a segmentationfault at the line : cout << b[0][0];
Someone can tell me what I should do to fix my code?
#include <iostream>
using namespace std;
int** gettab(int tab[][2]){
return (int**)tab;
}
int main() {
int a[4][2] = {{0, 0}, {1, 0}, {2, 0}, {2, 1}};
int ** b = gettab(a);
cout << b[0][0];
return 0;
}
...
Are there any advantages to compiling my Windows application with winelib for Linux users? Why not just give them the .exe and let them run it with Wine? Seems just like extra work for no gain.
...
I am writing an MFC application that doesn't use .NET (CLR support is set to No Common Language Runtime support in the project settings). However, I get an SEHException thrown when I quit the application in Release build. Debug build gives me an assertion error, but the error window disappears in about half a second after it pops up (so...
is this file with namespace Gdiplus in c++ managed or unmanaged code?
...
I want to read then store the content of a file in an array, but this isn't working:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string content,line,fname;
cout<<"Execute: ";
cin>>fname;
cin.ignore();
cout<<endl;
//Doesn't work:
ifstream myfile(fname);
if(!...
I had a question about C++ destructor behavior, more out of curiosity than anything else. I have the following classes:
Base.h
class BaseB;
class BaseA
{
public:
virtual int MethodA(BaseB *param1) = 0;
};
class BaseB
{
};
Imp.h
#include "Base.h"
#include <string>
class BImp;
class AImp : public BaseA
{
public:
...
How do you get how many bytes were read with the ifstream::read function?
Tell is saying the file is 10 bytes and windows says it is 10 bytes too but there are only 8 bytes in the file so when I read it, it is only reading the 8 bytes so I end up with too large of a buffer.
...
Suppose I have a class Base which has a member variable A* my_hash.
I also have class Extended which inherits from class Base. I also have a class B
which extends A.
class Base{
Base(): my_hash(new A) {}
//methods which use my_hash
protected:
A* my_hash;
};
class Extended:public Base{
//methods which use my_hash from A
//I can...
i am getting this error and i dont know why or understand the reason:
vector<double> fourier_descriptor(Gdiplus::Bitmap myBitmap)
{
vector<double> res;
Contour c;
vector<Pixel> frame;// = c.GetContour(p);
frame = c.GetContour(myBitmap);
return res;
}
the error is in this line
frame = c.GetContour(myBitmap);
...
I'm trying to decide what the best option would be for when an object has some traits that won't change, and are needed throughout its functions.
Static const members
Const members
It seems to me like the real reason for a static member is to have a variable that can be changed, and thus affect all other objects of the same class. Ho...
In Visual Studio (2008) is it possible to force the Post-Build Event for a C++ project to run even if the project is up-to-date?
Specifically, I have a project which builds a COM in-process server DLL. The project has a post-build step which runs "regsvr32.exe $(TargetPath)". This runs fine on a "Rebuild", but runs on a "Build" only if ...
How is the destructor for the vector managed when adding elements to this list? Is the object destroyed correctly when it goes out of scope? Are there cases where it would not delete the object correctly? For example what are the consequences if "table" was a child of object, and we added a new table to a vector of object pointers?
vect...
Right now when I try a loop that contains something like:
mouse_event(MOUSEEVENTF_MOVE,dx,dy,0,0);
The mouse tends to move more than (dx,dy). Researching this online, I think it's because of the acceleration applied by the operating system. How can I move the mouse an absolute amount?
MOUSEEVENTF_ABSOLUTE seems to maybe be what I'm ...
I keep hearing mostly from electrical engineers that C is used for fpga work.
What about C++? Are there any disadvantages to using C++? I would think that the parallelism desired when programming for hardware would be better served by C++ more than C, no?
Also what do I use after that to make compatible c++ with the hardware?
...
I'm writing some code that utilizes the boost filesystem library. Here is an excerpt of my code:
artist = (this->find_diff(paths_iterator->parent_path(), this->m_input_path) == 1) ? (*(paths_iterator->parent_path().end() - 1)) : (*(paths_iterator->parent_path().end() - 2));
album = (this->find_diff(paths_iterator->parent_path(), this->m...
how to have a shared variable in library across all application in linux (c++)?
...