I am trying to create a function that conjugate a complex number
for example A(2, 3) will turn into A(2,-3) by typing ~A
i have done a little code below but i guess it's wrong, i hope you can help me slove this.
i have quoted the part that i did wrong in the code below.
#include <iostream>
using namespace std;
class Complex
...
This works fine:
std::vector<int> v;
v.push_back(123);
but this throws a std::length_error:
std::vector<uint32_t> v;// or vector<unsigned __int32>
v.push_back(123);
It seems to be triggered by resizing, because
std::vector<uint32_t> v;
v.reserve(2);
triggers a debug assertion "iterator not dereferencable".
This occu...
Hi,
I have a code which looks like this:
class Parent
{
auto_ptr<Resource> ptr2Resc;
public: void parentMethod(int i )
{
SomeOtherClass someOthrPtr = new SomeOtherClass(ptr2Resc);
}
};
The ctor of SomeOtherClass:
SomeOtherClass(auto_ptr<Resource> ptrRes);
So now when i call parentMethod, the auto_ptr gets swapped and the ptr2Res...
We have a large MFC/C++ Visual Studio 2005 solution which currently consists of two projects:
Code (around 1500 .h/.cpp files, linked dynamically to MFC)
Resource DLL (we translate the resources using an external tool)
What options do we have (lib, dll, ...)?
Where do we start?
Is there a technical sample of this or a tutorial (I ...
So I'm new to socket programming. For the past day, I have been trying to figure out a problem with my "Unregister".
So far, I can register a user. But when I unregister only one byte is sent. And I'm not sure how to fix this:
Sorry for my bad coding. Scroll down to client.cpp, that is where my recv for unregister only receives 1 byte...
After I do, say
Foo* array = new Foo[N];
I've always deleted it this way
delete[] array;
However, sometimes I've seen it this way:
delete[N] array;
As it seems to compile and work (at least in msvc2005), I wonder:
What is the right way to do it?
Why does it compile the other way, then?
...
Hi,
I need to implement a character encoding conversion function in C++ or C( Most desired ) from a custom encoding scheme( to support multiple languages in single encoding ) to UTF-8.
Our encoding is pretty random , it looks like this
Because of the randomness of this mapping, I am thinking to use std::map for mapping our encoding t...
Hi, I am trying to implement example of visitor pattern, but I have trouble with circular dependecies of declarations of classes. When I do forward declaration of class Visitor, classes Russia and England doesn't know that Visitor has method visit, but when I extend forward declaration of Visitor for method accept, I need to use classes ...
I would like to now how to pass a standard Boolean Type in Ada through the Interfaces.C package in order to call a DLL function.
The Interfaces.C package does not contain the Ada Boolean type since the boolean type does not exist in ANSI C.
I have a DLL function written in C++ whose exported function prototype has an argument of type Boo...
Hi, I wrote some code but I am unable to compile it:
#include <cstdio>
#include <vector>
using namespace std;
class Visitor;
class Land {
public:
virtual void accept(const Visitor *v);
};
class England : public Land {
public:
void accept(const Visitor *v);
};
class Russia : public Land {
public:
void accept(const...
struct DummyStruct{
unsigned long long std;
int type;
};
DummyStruct d;
d.std = 100;
d.type = 10;
/// buggy printf, unsigned long long to int conversion is buggy.
printf("%d,%d\n",d.std, d.type); // OUTPUT: 0,100
printf("%d,%d\n", d.type, d.std); // OUTPUT: 10,100
printf("%lld,%d\n",d.std, d.type); // OUTPUT: 100,10
...
I'm porting a Windows application to Linux and I have a synchronization problem.
In Windows I'm using a system-level named mutex to sync access to a shared memory block.
How do I emulate that in Linux? I've created a SystemV semaphore, using semget. The problem is that it is not reentrant, if I already hold it it will block, unlike on ...
I only want it to update server_record. Dont send any messgaes. What can I remove so it dont say "New record of players online is: 2839". Can I remove everything under query.str("");? I have no idea what char buffer[50]; do. I dont wanna mess anything up. And How can u get current time in c++? I want to insert the current time in the tab...
I'm am looking for online tutorials/books, which assume a solid knowledge of OOP/Design patterns concepts and stress on differences (both conceptional and syntactical) between C++ and Java thus allowing for a rapid development in the latter.
Thank you very much in advance, appreciate your time.
...
I am reletively new to c++ programming can anyone please tell me how does Direct-X SDK is helpful and how does it works and how can we use it in game programming.I Downloaded it and I found lots of header files and documentation also tells something about game programming.
...
When a friend function is included in the namespace, its definition needs to be prefixed with namespace to compile it, here is the sample code:
test.h:
#ifndef TEST_H
#define TEST_H
namespace TestNamespace
{
class TestClass
{
public:
void setValue(int &aI);
int value();
private:
int i;
fr...
I have a class that goes like this:
class myType
{
union {
float data[4];
other_vector4_type v
} ;
typedef union {
float data[4];
other_vector4_type v
} myType-internal_t;
<various member functions, operator overloads>
}
Now I want to use this type in my vertex buffer, but the sizeof() isn't as expe...
I am about to make the transition from using standard FILE pointers from some older code to using C++ streams but I need to have LARGEFILE seeking support (the compiler flags that activate this support are: *-D_FILE_OFFSET_BITS=64* et al) which I am able to obtain by using the *off64_t* datatype.
My original question was answered regar...
hi,
i have been going through some code and came across a statement that somehow disturbed me.
typedef GLfloat vec2_t[2];
typedef GLfloat vec3_t[3];
From my perspective, a statement such as
typedef unsigned long ulong;
Means that ulong is taken to mean unsigned long
Now, can the statement below mean that vec2_t[2] is equiv...
Hi, I am trying to understand what multiple dispatch is. I read a lot of various texts but I still have no idea what multiple dispatch is and what it is good for. Maybe the thing I am missing is piece of code using multiple dispatch. Please, can you write a little piece of code in C++ using multiple dispatch so that I can see it cannot b...