c++

Declare a class/struct

For example, i have a struct and I'm using static function of class to initialize its members. how can i tell the complier that the class exists but it is defined after the structure S? struct S { S() { x = C::GetX(); //static functions, GetX() and GetY() y = C::GetY(); } int x; int y; }; class C { /.... /...

what is the size of an abstract class and why can't we create objects of an abstract class?

what is the size of an abstract class and why can't we create objects of an abstract class? ...

Is copy constructor used for object initialization? How does it works and what is the difference B/W deep copy and shallow copy?

Is copy constructor used for object initialization? How does it works and what is the difference B/W deep copy and shallow copy? ...

Listening for IPv6 multicasts on Linux

I'm trying to get a simple multicasting example to work on Linux (I've tried both RHEL 4 2.6.9 and Ubuntu 8.04 2.6.24). The general idea is that I would like the server to bind to a unicast address and then add itself to the group ff02::1. I would then like it to receive multicasts sent to ff02::1. The code below works on Mac OS X 10.5 (...

Cannot assign pointer in a self-referential object in Visual Studio 2010

Hi all, I am learning C++ and i currently have some questions that i don't know the answers. I create this header file Object1.h and can compile this file but when i run the Test.cpp, Visual Studio throw an error because of access violation by *sibling. The strange thing is I can run it using Dev C+ and it return only value 2.Therefore I...

How does Java drag C++ coders "halfway to Lisp?"

Possible Duplicate: How is Java inspired by Lisp? From Paul Graham: "We were after the C++ programmers. We managed to drag a lot of them about halfway to Lisp." Guy Steele, co-author of the Java spec I've thought about this, and it just doesn't make any sense. Out of all the "Lisp-ish" features on Graham'...

Define array, then change its size....

I come from a java background and there's something I could do in Java that I need to do in C++, but I'm not sure how to do it. I need to declare an array, but at the moment I don't know the size. Once I know the size, then I set the size of the array. I java I would just do something like: int [] array; then array = new int[someSi...

0x2e2e2e2e in GDB backtrace?

I've got a SIGSEGV I'm trying to track down in my code, but I'm getting strange backtraces like this out of GDB: #1 0x00407d15 in print_banner (msg=0x2e2e2e2e <Address 0x2e2e2e2e out of bounds>) at ../include/test_util.hh:20 #2 0x2e2e2e2e in ?? () #3 0x2e2e2e2e in ?? () #4 0x2e2e2e2e in ?? () #5 0x2e2e2e2e in ?? () #6 0x2e2e2e...

Floating point and integer ambiguity

I have a function (and a constructor) that should be able to take integer and floating point values. In fact I want it to take an int64_t or a long double, so what I want is, class Foo { public: Foo(int64_t value=0); Foo(long double value); }; However if I do this and try Foo f = 1; the compiler complains about the convers...

Difference between pointer and smart pointer

Can you tell me what is wrong with this piece of code? I got asked this in an interview and I am not sure what's wrong with it tClass is a test class with a method printSomething that prints members of tClass. tClass * A = new tClass(); f(A); A->printSomething(); auto_ptr<tClass> * B = new tClass(); f(B); B-> printSomething(); or ...

setup include path in eclipse CDT in mac os (headers from framework)

for example I need to include a header #include <OpenGL/glext.h> while it is actually a header file glext.h under OpenGL.framework/Headers/. Therefore it is no way to give eclipse a physical path about "OpenGL/glext.h", and I always get unresolved inclusion warning. I can still build and run them (with managed makefile project) but ...

Having problem with a surjection problem.

Hello, I am a fairly decent programmer, but I suck at math. I need help understanding this problem so i can write a program to solve it. I dont really understand the formula. https://cs.harding.edu/easel/cgi-bin/view?id=4896 ...

C++: How do I avoid pointer invalidation in my insert function?

In my data structures course, we are creating a basic vector class. In my header, there is a member function for inserting new values into the vector. If the capacity of my vector is big enough for the insertion of one value, the program runs fine. However, if the vector needs to grow, I run into pointer errors. After hours of trying to ...

interface of the list in c++

hello everyone, I found some interface for the list: and there I found this constructor template<typenameT> ... list(size_tnum, constT& val = T()); ... can somebody explain what is this: constT& val = T() thanks in advance ...

C++, Access Violation using OpenCV to get RGB value of pixel

I'm trying to use OpenCV to find the RGB values of a pixel in an image. so far I've tried the following: int blue = ((uchar *)(img->imageData + y*img->widthStep))[x*img->nChannels + 0]; int green = ((uchar *)(img->imageData + y*img->widthStep))[x*img->nChannels + 1]; int red = ((uchar *)(img->imageData + y*img->widthStep))[x*img->nChann...

Intercept mouse input

I was wondering if there is a way to intercept and modify mouse input before it gets to windows? What I'm wanting to do is intercept mouse motion events, apply some custom scaling and acceleration to the values, and then continue passing them along. I'd need something that can do this before the inputs get to the raw input API or Direct...

C++ Syntax Question

What does the | mean? m_pD3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE); ...

C++ and Eclipse project - how to work out what headers to include, and what class to forward declare.

I'm building a C++ project in Eclipse using a third party implementation of gcc. The makefile is auto-generated and the object rules are listed in alphabetical order ( I'm not sure if that's relevant ). I can't seem to create the correct configuration of #include directives and forward declarations so that it compiles. I'm guessing - a...

boost::gil Interleaved_view

Hi guys, I'm having some trouble figuring out the boost image library. I could not find any exact documentation on how to use the interleaved_view function included in the boost::gil library. More specifically, I don't know exactly what binary format the raw data is supposed to be stored in. The only mention of it I could find was in...

8 Queens using One array

Possible Duplicate: Dumb 8 Queens problem in C++ using goto and backtrack Having problems understanding how to use an one dimensional array to implement the eight queens problem. Also can't figure out how to print the array to print out all possible solutions. #include "stdafx.h" #include <iostream> using namespace std; in...