Do we have to explicitly define a default constructor when we define a copy constructor for a class?? Please give reasons.
eg:
class A
{
int i;
public:
A(A& a)
{
i = a.i//Ok this is corrected....
}
A() { } /Is this required if we write the above copy constructor??...
Hi all,
I am kind of newbie on C++, and working on a simple program on Linux which is supposed to invoke another program in the same directory and get the output of the invoked program without showing output of the invoked program on console. This is the code snippet that I am working on:
pid_t pid;
cout<<"General sentance:"<<en...
Hello,
So I'm looking through some code, and I see this:
class whatever
{
public:
void SomeFunc(SomeClass& outVal)
{
outVal = m_q.front();
m_q.pop();
}
private:
std::queue<SomeClass> m_q;
};
This doesn't seem like outVal would be a valid reference any more... However, it appears to work.
I've see...
Having seen the advantages of metaprogramming in Ruby and Python, but being bound to lower-level languages like C++ and C for actual work, I'm thinking of manners by which to combine the two. One instance comes in the simple problem for sorting lists of arbitrary structures/classes. For instance:
struct s{
int a;
int b;
};
vector<s...
I've debugged my program and the arrays seem to be allocated well. However for some strange and stupid reason, the code doesn't output the arrays into the file.
Please help me spot my bug or such!
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;
void sRecSort(string *n, int *s, string...
For some reason the following doesn't crash like my program does, but I'm pretty sure it's similar in design. For one, the output's not correct. It outputs something similar to:
0x537ff4 5471612
While the main program outputs (nil) for the pointer address.
The key to the problem might be display_ in Drv.
Here's the code:
#include <...
Visual Studio is yelling at me about using itoa()... saying to use _itoa instead? It looks to me like they are the same function... what gives?
...
I have a small application that redirects the stdout/in of an another app (usually command prompt or bash for windows). The problem is that if the connection is interrupted the my process has no idea and it never closes because of this line:
WaitForSingleObject(childProcess.hThread, INFINITE)
I was thinking of having a loop with somet...
I came across this as I was trying to learn array and vectors in c++. What is the "paging effect" mentioned in the post? Also, just to check my own understanding, I think vector uses more time is because of the dynamic memory allocation. Am I right?
additional question:
but with vector<int> arr( 10000 ) isn't there already enough memo...
I have a server application that writes to a popen("myCommand", "w") file descriptor in a separate thread and if the command passed to popen() results in any output to stdout or stderr, the my application exits. However, this is only an issue when my server application was invoked via inetd, if I used ssh to launch the server, it does n...
I have a server application that can be summoned for the client using inetd. However, if I try to attach to the server process that was launched with inetd, I get the following response: ptrace: Operation not permitted.
gdb --annotate=3 /my/app/here <processId>
Current directory is /usr/local/bin/
GNU gdb 6.8
Copyright (C) 2008 Free S...
Hi, I was looking at the escape sequences for characters in strings in c++ and I noticed there is an escape sequence for a question mark. Can someone tell me why this is? It just seems a little odd and I can't figure out what ? does in a string. Thanks.
...
I have a file,named f1.txt, whose contents are
75 15 85 35 60 50 45 70
Here is my code to read each integer and print them.
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
fstream file("f1.txt", ios::in);
int i;
while(!file.eof()) {
file >> i;
cout << i << " ";
}
return 0;...
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "Input a Sentence: ";
cin >> x;
{
char* string = x;
int letter_count[26];
// Initialization
for(int i=0; i<26; letter_count[i++]=0);
// Counting the number of letters
for(int i = 0; string[i] != '\0'; i++) {
if(string[i] > 64 && strin...
I've got a basic HTTP client set up in C++, which works ok so far. It's for a school assignment, so there's lots more to do, but I'm having a problem.
I use the recv() function in a while loop, to repeatedly add pieces of the response to my response buffer, and then output that buffer each time. The problem is, at the end of each piece ...
What could cause this?
Here's the stack trace:
#0 0x0645c0f5 in std::_Rb_tree_increment (__x=0x83ee5b0)
at ../../../../libstdc++-v3/src/tree.cc:69
#1 0x0805409a in std::_Rb_tree_iterator<std::pair<std::string const, Widget*> >::operator++ (
this=0xbffff144)
at /usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4...
I have a dll produced by a third party that has some sort of internal datastructure that limits it's size to X elements.
So basically, it has a Queue with X as the limit.
Now from what I've known DLL's are per process, but is it possible to load a DLL more than once? Maybe per thread? In C#? or in C++/CLI?
I'm trying to load a native ...
Is there any free open source library (in C/C++) for sockets that is widely used and supports wide range of operating systems (Windows, Unix/Linux, FreeBSD etc). Just like pthreads.
Otherwise the only solution left would be to write socket wrapper for each operating system. Or would writing a wrapper against winsock and GNU C sys/socket...
I am using C++ GDI+ to open a gif
however I find the frame interval is really strange.
It is different from played it by window's pic viewer.
The code I written is as follow.
pMultiPageImg = new Bitmap(XXXXX);
int size = m_pMultiPageImg->GetPropertyItemSize(PropertyTagFrameDelay);
m_pTimeDelays = (PropertyItem*) malloc (size);
m_pMult...
There's a function, written in C++ and compiled as DLL, which I want to use in my Delphi application.
Scraper.cpp:
SCRAPER_API bool ScraperGetWinList(SWin winList[100])
{
iCurrWin=0;
memset(winList,0,100 * sizeof(SWin));
return EnumWindows(EnumProcTopLevelWindowList, (LPARAM) winList);
}
Scraper.h:
#ifdef SCRAPER_EXPORTS...