Friend functions should be able to access a class private members right?
So what have I done wrong here? I've included my .h file with the operator<< I intent to befriend with the class.
#include <iostream>
using namespace std;
class fun
{
private:
int a;
int b;
int c;
public:
fun(int a, int b);
void my_swap();
...
Is there any way to Blit a zoomed (in) version of a certain image/sprite using SDL? (Besides manually saving a zoomed version of the image..)
Thanks :-)
...
Hi,
Recently I have been looking into OpenGL, and I've got up to the stage were I want to texture things. I thought I would start with texturing a simple cube.
I currently have this code, and understand fully how it works:
#include <glut.h>
#define WINDOW_WIDTH 400
#define WINDOW_HEIGHT 400
float angle = 30.0f;
void Draw() {
glLoa...
how to simulate a "escape key" as if an escape key has been pressed, at the end of a string sequence in c++?
i need to provide the stdin input, which accepts string data until Escape key is pressed,
for that it receives the characters correctly, but how do i send an 'escape key stroke' finally?
...
i have tried to implement following code
#include <iostream>
#include <bitset>
using namespace std;
int main(){
//bitset<4>mybits;
//cout<<mybits<<endl;
int a[]={3,1,4,5,7,8};
int max=a[0];
int t=sizeof(a)/sizeof(a[0]);
for (int i=1;i<t;i++){
if (a[i]>max){
max=a[i];
...
Hello,
I'm trying to add a Sokoban solver (written in C++) to my program in C# (I have got a class in my program that handles marshalling of C++ interface). My program loads solver.dll library which loads solver.exe. Solver.dll and Solver.exe communicate via pipes.
The problem is that when I run my program in Visual Studio (debugging) ...
When moving an application from 32bit to 64bit, where will increased memory usage occur?
I understand that pointers will double in size, I suspect that the chars in a string are 'bunched' to use memory more efficiently (so will not use much more memory).
Where else would memory usage increase? Is there anywhere that it would decrease, ...
I've been hunting bugs for the past three days and I've kind of given up. I've plowed through all the samples in the OpenAL SDK and the Vorbis examples, but to no avail, so I hope someone can help me.
The problem:
I record audio using OpenAL, and for debug reasons i output it to C:/out.wav which i can then play with any audio player of...
Hello all,
I'm wondering if its at all possible to sandbox a dynamically linked library via dlopen and friends. The aim is to recover from an error within the library without tearing down the hole application e.g SEGFAULT, etc...
Anyone had any experience in this area?
Cheers
...
I am a beginner in C#
I wonder how to write in C# C's
static void example(const char *filename)
{
FILE *f;
outbuf_size = 10000;
outbuf = malloc(outbuf_size);
f = fopen(filename, "wb");
if (!f) {
fprintf(stderr, "could not open %s\n", filename);
exit(1);
}
fwrite(outbuf, 1, outbuf_size, f);
fclose(f);
}
Plas...
Pretty new to c++, i have a rather (i think) stupid question about a piece of code :
class DataStream
{
protected:
DataStream(void) { };
public:
DataStream(int Length);
~DataStream(void);
...
void* DataPtr;
int Length;
};
I do have a class similiar to this and i want to assign to DataPtr a pointer to some data allocated.
When i...
#include <iostream>
using namespace std;
#define max 10
class stack{
private:
int arr[max];
int top;
public:
stack(){
top=-1;//empty initialy stack
}
void push(int i){
top++;
if (top<max){
arr[top]=i;
}
else{
cout<<"stack full"<<endl;
...
When a vector is created it has a default allocation size (probably this is not the right term to use, maybe step size?). When the number of elements reaches this size, the vector is resized. Is this size compiler specific? Can I control it? Is this a good idea?
Do repeated calls to vector::size() recount the number of elements (O(n) ca...
When I create a std::vector of objects, the constructor of these objects is not always called.
#include <iostream>
#include <vector>
using namespace std;
struct C {
int id;
static int n;
C() { id = n++; } // not called
// C() { id = 3; } // ok, called
};
int C::n = 0;
int main()
{
vector<C> vc;
vc.resize...
auto_ptr (shared_ptr as well) try to make their use as transparent as possible; that is, ideally, you should not be able to tell a difference whether you're using an auto_ptr or a real pointer to an object. Consider:
class MyClass
{
public:
void foo() { }
};
MyClass* p = new MyClass;
auto_ptr<MyClass> ap(new MyClassp);
p->foo(); ...
I am trying to convert a math library written with VS so it will compile though GCC. The trouble is, I have a lot of overloaded operators that look like this:
template<typename T>
inline quaternion<T> operator+(quaternion<T> &a, quaternion<T> &b)
{return quaternion<T>(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);}
and so on.
The problem is: Thes...
I've got a third-party library that generates a ton of warnings, even under /W3. Is there a way for me to tell the compiler, "disable C4244 for any file included from this directory, or its subdirectories"? Of course, I don't want to disable the warning in our own codebase, nor do I want to have to track down every possible include and...
I came a across a new problem when using templates. This is me being a little creative from a book I recently read, expanding his ideas, and it has this code example.
Say you have a templated Array2D class. And you have this method (Array2D::WriteFile):
bool WriteFile( const char* p_filename )
{
FILE* outfile = 0;
int writt...
If so, why? Why doesn't it use the copy constructor of the value type?
I get the following error:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/vector.tcc: In member functio
n `ClassWithoutAss& ClassWithoutAss::operator=(const ClassWithoutAss&)':
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/vector.tcc:238: instantiate
d f...
I just need what to do to be simplified. But if you write the source code I still want to know how and what u did explained.
Write a function that sums all the integers in a matrix of integers using the following header:
const int SIZE = 4;
double sumMatrix (const double m [] [SIZE] , int rowSize, int columnSize) ;
Write a test pro...