Another c++ pointer deletion question is in the following example:
class Foo {
public:
int *p;
~Foo() {
delete p; p = NULL;
}
};
Foo *f1 = new Foo();
Foo *f2 = new Foo();
f1->p = new int(1);
f2->p = f1->p;
delete f2; // ok
delete f1; // no error?
Why I did not get error when calling "delete f1"? didn't I delete th...
Hello..
I have a program like this
int main(){
char c;
int i; /* counter */
double d;
return 0;
}
if I want to comment out char, int and double, and just have return uncommented, can I do it? the comment that's already there stops the comment..
Is there an easy/fast way to comment that out?
...
Hi,
I have an application that does some Monte Carlo simulation. For each run, a 12MB file is loaded into a std::vector<MyData>. The object which loads and stores the data is referenced by a boost::shared_ptr which is removed from the stack when the run finishes.
I see the memory usage of the application grow in Windows Task Manager to...
Hi All,
Is anybody aware of a way to enable OpenGL stereo while using a layered window in Windows 7?
...
I need a method that would allow me to read all the HTTP traffic on a local machine, and to change this traffic on-the-fly. Basically, I need to change the content on any web page opened in any browser at the machine.
Any thoughts?
...
I would like to implement a custom Windows Media Foundation Scheme Handler, IMFSchemeHandler, that returns a byte stream from a file on disk.
I am struggling to work out how this should be done from the documentation on Microsoft's website and I can't find any samples relating to this. I am not very experienced with C++ which might be c...
I was required to write a program that generate random results of 10 sport games where 10 countries are involved, and display the medal tally based on the results.
I was able to generate the games' result but have no idea how to sum up the results (i.e. the number of different medals earned by each country).
Below is part of my code to...
given a string literal in c++ i have to remove toxic words like stupid etc by ###.
Suppose i have my toxic words in an array like
char[][]={"...",".."...and more...}
and my string is like
char str[]="......."
any particular library func that could help me here.
thanks in advance for help
...
I need a common rule for warnings in x64 mode. Which way is better?
Consider the following lines of some code
const int N = std::max_element(cont.begin(), cont.end()) - cont.begin();
or
const int ARR_SIZE = 1024;
char arr[ARR_SIZE];
//...
const int N = std::max_element(arr, arr + ARR_SIZE) - arr;
It is my usual code. I have no pr...
Hi All,
Is anybody aware of a way of grabbing images from a DVD using DirectShow and C++? The sample grabber is not supported when using the DVD renderer and if I use GetCurrentImage, which is part of the VMR9 windoless control, it doesn't appear to work.
...
This question has been bothering me for a while now. Let's consider the two following programs:
#incude <iostream>
int main()
{
std::cout << "Hello, World!";
}
and
int main()
{
int x = 5;
int y = x*x;
}
Windows:
The first example, naturally, requires some system .dll's for the console. I understand that. What about the se...
Reservation Problem
there are 67 seats in train . there are only 5 seats in a row and in last row there are only 2 seats. One person can reserve only 5 seat at a time. If person reserving seat , the care is taken that he may get all in row. if seats are not available in row then the arrangement is so that person group get nearby seats.
...
I am talking about This. Now, my problem is that I have an interface header file which I really don't like to do any implementation in. Can a class derived from a base class declared in that header adopt this idiom? Because as far as I understood, I have to define the (protected) copy constructor for the base class which means that I hav...
In KDE 4.5 the KIO::Scheduler::scheduleJob is deprecated.
What should I use instead of this Public Member Functions? What is the proper way to schedule the job now?
E.g. until now I have used:
KURL url("http://developer.kde.org/documentation/kde2arch/index.html");
KIO::TransferJob *job = KIO::get(url, true, false);
KIO::Scheduler::sch...
#include <iostream>
#include <string>
class c1
{
public:
static std::string m1;
static unsigned int m2;
};
//std::string c1::m1 = std::string;
unsigned int c1::m2 = 0;
void main()
{
c1 a;
//std::cout<<a.m1<<std::endl;
std::cout<<a.m2<<std::endl;
}
In this program enabling the two remarked lines causes an error on the first.
...
Hi all,
I have a curl_multi_exec call to about 500 sites which it calls via an array loop:
I am using the simplified code:
http://github.com/kminkler/php-curl-multi/wiki
but it gets VERRRY slow (19 minutes) towards the end...
do I need to remove the handle every time is this a memory issue;
Would you rec. writing a C++ curl routine...
Hi,
I had been doing some file IO in a project i am currently working on and so far I have been reading in a whole block of data using the following fast and convenient method:
struct Header { ... };
class Data { ... };
// note that I have not used compiler directives to pack/align/order bytes
// partly because I don't know how to.
He...
Hi All,
I need to write a piece of code which will invoke a process and dynamically issue commands to the process. For example, I may have to run FTP and then when the process is up, I've to issue ftp commands to this process. I need to do this in C++. I don't have a single clue of where to start.
...
Hello,
my question is about how to template'ize the name of a class member that should be used.
Maybe a simplified & pseudo example:
/**
Does something with a specified member of every element in a List.
*/
template<membername MEMBER> // <-- How to define such thing?
void doSomething(std::vector<MyClass> all){
for( i=0; i < all....
Ok, so I am using QT and C++ as my environment.
I draw out a QGraphicsView in my UI.
I then create a scene and add lines to that scene. I run through an array of 5000 points and draw lines connecting each point.
QGraphicsScene *scene = new QGraphicsScene();
QPen pen2 = QPen(Qt::blue, 8.0);
int j=1;
for (int i=1; i<5000; i++)
{
...