I was trying following code in which I defined copy c'tor explicitly to solve aliasing problem.
But code is giving runtime error.
#include<iostream>
#include<cstring>
using namespace std;
class word
{
public:
word(const char *s) // No default c'tor
{
str=const_cast<char*>(s);
cnt=strlen(s);
}
word(const ...
I'm writing small program (C++) to encrypt/decrypt files. Before decryption I would like to check if password given by user is correct. My idea:
Add at the beginning of file some string (for example: "GOOD");
Encrypt file
When decrypting first decrypt the beginning of file and check for "GOOD" string
Is this correct?
...
GetVolumePathName() API failed and GetLastError() returned ERROR 158: ERROR_NOT_LOCKED.
What is the reason for this error and how to overcome it?
...
Hi All
I would like to read some data from a stream I have using std::getline.
Below a sample using the std::cin.
std::string line;
std::getline( std::cin, line );
This is a blocking function i.e. if there is no data or line to read it blocks execution.
Do you know if exists a function for checking data availability before calling s...
I have recently inherited a program written in Managed C++ from some guy who just retired. After spending some time digging through it, I can honestly say that at least 95% of it belongs on thedailywtf. However, I am now tasked with modifying it and porting it over to a language I'm comfortable with.
The program itself takes in many m...
Hi,
I have a problem putting data into an unordered_map using a struct as key:
typedef struct osdpi_flow_identificator {
u32 lower_ip;
u32 upper_ip;
u16 lower_port;
u16 upper_port;
u8 protocol;
} osdpi_flow_identificator_t;
// custom hash function for osdpi_flow_identificator
struct osdpi_flow_hash {
std::size_t operator() (osd...
here is code to implement linked list i hope you understand main purpose of this code such kind of code is written in java and i am trying to implement in c++
#include <iostream>
using namespace std;
class link {
public:
int idata;
double ddata;
link ( int id,double dd){
idata=id;
ddata=dd;
}
public :
...
hi everybody,
i just noticed, that glBufferData fails silently when i try to call it with size: 1085859108 and data: NULL.
Following calls to glBufferSubData fail with a OUT_OF_MEMORY 'Exception'. This is on Windows XP 32bit, NVIDIA Gforce 9500 GT (1024MB) and 195.62 Drivers.
Is there any way to determinate if a buffer was created suc...
Hi,
The main() function creates a thread that is supposed to live until the user wishes to exit the program. The thread needs to return values to the main functions at periodic intervals. I tried doing something like this, but hasn't worked well -
std::queue<std::string> q;
void start_thread(int num)
{
std::string str;
//Do some pro...
In section 7.1.1 of the book "The C++ Programming Language" the author states:
"inline function still has a unique address and so do the static variables of an inline function"
I am confused. If I have an inline function then it can't have address. Does this happen in C also?
...
I was wondering if someone could explain to me what the #pragma pack preprocessor statement does and more importantly why one would want to use it. I checked out the msdn on this http://msdn.microsoft.com/en-us/library/2e70t5y1(VS.80).aspx, which offered some insight, but I was hoping to hear more from people with experience. I've seen i...
here is full code from algorithm and data structure in java written in c++
#include <iostream>
using namespace std;
class link {
public:
int idata;
double ddata;
link *next;
link ( int id,double dd){
idata=id;
ddata=dd;
}
public :
void display(){
cout<<idata<<"=>";
cout<<ddata;...
Hi all,
i've to develop a stack trace walk to our win32 API plattform support to catch any exception with a behaviour of a JAVA stacktrace. Actually we got a full functional implementation for Linux plattforms.
First i've tried to implement a stackwalk using the win32 CaptureStackBackTrace API
mechanism. But this method is not integrat...
I can't find a tutorial showing me how this works and I don't get it. I'd like to use it to draw dashed lines since I have an algorithm that generates triangles and would like it to skip some after a certain distance has been reach (a bit like glLineStipple)
Thanks
...
Is there a way in C++ to check if an ostream object is cout or a ofstream object?
Something like:
ostream& output(ostream& out)
{
if (out == cout)
return out;
else
{
out << "something different because its not going to the console" << endl;
return out;
}
}
The reason I want to do this, is that ...
I need to write a C++ application that reads and writes large amounts of data (more than the available RAM) but always in a sequential way.
In order to keep the data in a future proof and easy to document way I use Protocol Buffer. Protocol buffer however does not handle large amounts of data.
My previous solution consisted on creating...
I was just wondering why c++ ist that powerful and performant for developing games. I wrote a lot of games in c# and delphi, always using the timer component to make objects "move". Another option for the movement were loops, but they are definitely not performant.
So what technique does c++ use that users can develop performant games?
...
Hi,
So I'm trying to pick C++, and to do so I decided to write a generic Group class using templates, that takes a Type and size as template parameters:
in group.h:
#ifndef __GROUP_H
#define __GROUP_H
#define MAX_SIZE 10
/**********************************************************
* Define a Group class that handles a collection of m...
Hello, If I have some class Basis, and derived from it Derived, inside basis I have friend function
friend int operator!=(const Basis&, const Basis&)
Inside derived class I don't have such function
So my question is if I have inside my main
If( derived1 != derived2 ) ...
why does it work? i don't have any constructor for casting f...
It seems that GMP provides only string serialization of the mpf (floating point) type:
mpf_get_str(), mpf_class::get_str()
The mpz (integer) type has an additional interface for raw bytes: mpz_out_raw()
http://gmplib.org/manual/Function-Index.html
Am I missing something? Does anyone know of another library that can serialize GMP flo...