Hi all,
While writing some code i came across this issue:
#include <iostream>
class random
{
public:
random(){ std::cout << "yay!! i am called \n" ;}
};
random r1 ;
int main()
{
std::cout << "entry!!\n" ;
static random r2;
std::cout << "done!!\n" ;
return 0 ;
}
When i try to compile this code i get the error
error: ârandomâ d...
Should a C++ (implicit or explicit) value constructor accept its parameter(s) by value or reference-to-const, when it needs to store a copy of the argument(s) in its object either way?
Here is the shortest example I can think of:
struct foo {
bar _b;
foo(bar [const&] b) // pass by value or reference-to-const?
: _b(b) { ...
Extends.
I thought I was being cool when I did something like:
bool hasParent()
{
return this->parentNode ;
}
Even with a (bool) cast, the warning still doesn't go away.
Where this->parentNode is NULL when there is no parent node.
But I'm getting:
warning C4800: 'Node *' : forcing value to bool 'true' or 'false' (performance w...
I wanted to know why the default value for a variable for a method of a class, cannot be a non-static method or member of the same class.
Is there a reason for that ? Could not the compiler provide to the method the position in the class of the non-static default value ?
I tried to google quickly for an answer but I could not come up w...
Follow up of this question:
When I do include <iostream> .
It happens that it includes many files from /usr/include .A grep "\usr\include" over g++ -E prog.cpp counted to about 1260 entries ;).
Is their a way to control including various files?
Platform: Linux
G++ version: 4.2.4
...
I want figure out the call sequence and functions to kernel32.dll
in a function example() in example.DLL.
In windbg, how to set breakpoint on all functions in kernel32.dll?
I tried bm kernel32!* , but seems not work.
...
Hello,
when I run my program everything goes fine. At the end it prints out this:
*** glibc detected *** ./streamShare: double free or corruption (fasttop): 0x08292130 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xcc2ff1]
/lib/tls/i686/cmov/libc.so.6[0xcc46f2]
/lib/tls/i686/cmov/libc.so.6(cfree+0x6d)[0xcc779d]
/usr/li...
I need to pass some data (integers) from one (C++) program to another (C#). What is the fastest way to do this?
P.S.: OS: Windows XP
...
What is the biggest "no-floating" integer that can be stored in a double C type (IEEE) without loosing precision ?
...
My program reads a list of integers from user input [ keyboard] and calculates some statistics
The user enters 'x' to terminate the input process.
So for example,
Enter integers separated by space ( enter x to quit) : 1 2 3 4 5 x
But now I want to include the inputs to be read from file redirection also. So if the numbers followed ...
I have a container of regular expressions. I'd like to analyze them to determine if it's possible to generate a string that matches more than 1 of them. Short of writing my own regex engine with this use case in mind, is there an easy way in C++ or Python to solve this problem?
...
I'm having a discussion about which way to go in a new C++ project. I favor exceptions over return codes (for exceptional cases only) for the following reasons -
Constructors can't give a return code
Decouples the failure path (which should be very rare) from the logical code which is cleaner
Faster in the non-exceptional case (no che...
Hi all,
I'm completely new to c++ and Qt.
I want to populate a QTextEdit object with QTextBlocks, how do I do that?
e.g. If I have the sentence "the fish are coming" how would I put each word into its own QTextBlock and add that block to QTextEdit, or have I misunderstood how QTextBlock actually works?
...
This is the provided function template I'm trying to use:
template <class Process, class BTNode>
void postorder(Process f, BTNode* node_ptr)
{
if (node_ptr != 0)
{
postorder( f, node_ptr->left() );
postorder( f, node_ptr->right() );
f( node_ptr->data() );
}
}
This is my call, and the function I'm passing:
v...
Hi. I am creating a simple Unix server written in C++ that simply waits for incoming connections, and then when a connection is established, it sends the requested data back to the client's browser to be displayed. I have everything working except for the sending of the data to the client. This is how it should work:
I start server and...
I have some .h files as follows (on Linux)
Source/Server/connect.h
Source/Server/message.h
...
I am developing another application that needs the two .h files but is in a different directory
Source/App2/..
How can I include the connect.h file in the App2 application, considering that I use perforce and everyone else working on the ...
I´m writing two litle c++ apps that must communicate. First one will be a service which, every once in a while, must alert the user for something. Since a service cannot create windows I designed the app to be two separate executables.
The service will use a notifier to communicate.
The service needs only to send text messages to the n...
So how i can do this? So that no member function can change the value of its data members once object has been initialized in C++.
...
So... I understand this might be subjective, but I'd like some opinions on what the best practice for this is.
Say I have the following header and .cpp file:
header:
// foo.h
class foo
{
public:
int bar(int in);
};
cpp:
// foo.cpp
int foo::bar(int in)
{
// some algorithm here which modifies in and returns the modified val...
I really like the console and got recently hooked on programming console applications using nCurses mainly in conjunction with the C programming language.
Unfortunately i think the ncurses API is totally borked and very hard to use, and the C++ bindings are undocumented.
So my question is, what is THE API to use for C++ console applic...