c++

Function help in c++

I'm trying to create a very simple function in c++ however I keep getting a "Link error". My code: #include <iostream> using namespace std ; int fun(int,int); main(){ int width,height,w,h,mult; cin>>width; cin>>height; mult = fun(width,height); int fun(int w,int h);{ w * h ; } cout << mul...

What do the terms platform and framework refer to?

Hi, I ran into this question many times ago and have seen the terms again and didn't know their real concept in computer engineering. What do platform and framework refer to? I see many terms like platform-independent and development platforms, and also same for frameworks, but i can't quietly understand them. Do they refer to librarie...

using QT destructors

hello everyone, I've just begun to study qt using qt-creator, I found some tutorials int which the author doesn't use d'tors at all? is it good practice? or it will be better to manage my objects destruction, thanks in advance ...

trying to receive a file over socket

sending and recieving file from tcp socket. Sending the file works however trying to save the file does not work. #include <cassert> #include <arpa/inet.h> #include <cstdlib> #include <iostream> #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <errno.h> #include <string.h> #include <fstr...

error: invalid operands to binary % (have 'double' and 'double')

I have a program I am writing that lists 100,000 prime numbers. It works fine for 10 numbers, but after so many numbers they turn into negative values. I changed the ints to long ints and that did not change anything, then I changed them to doubles and I get the error listed in the title. What should my variable be? Keep in mind I am...

C++ Using 3D Dynamic Arrays and Vectors

I'm new to C++ and getting a bit frustrated with it. Below, in pixelsVector, I am storing each pixel RGB float-value in Pixel and want to dump all the values to a byte array with pixelsArray so I can output to an image file. HEIGHT and WIDTH refer to the image dimensions. The code below works fine, but I need to specify the sizes of ...

How to configure mouse enhance pointer precision programatically

How to configure mouse enhance pointer precision programatically in C++? I know that have some useful commands like SystemParametersInfo, for speed, ... int x = 15; SystemParametersInfo(SPI_SETMOUSESPEED, NULL, reinterpret_cast(x),SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE ); ... but I cannot find enhance precision---- ...

OpenGL: Render to FBO using multiple textures

Hi, I'm experimenting with a renderer. What I want is to write a color buffer and a normal buffer to two separate textures. I got that part figured out. However, the color buffer is supposed to be a combination of two textures. This should do the trick: glActiveTexture(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); g_Tex->Bind(); glActiv...

"no base classes of the same type as the first non-static data member"

I asked this a while ago on comp.std.c++ and got no reply. I'm just going to quote my post there with little modification. Is the last requirement of standard-layout classes, 9/6, necessary or useful? A footnote explanation is provided: This ensures that two subobjects that have the same class type and that belong to the sa...

How do I count the zeros and ones in a file?

Given a file (binary or textual), what is the fastest or most elegant way in C++ to count the ones and zeros in the binary representation of that file? ...

Choosing between std::map and std::unordered_map

Now that std has a real hash map in unordered_map, why (or when) would I still want to use the good old map over unordered_map on systems where it actually exists? Are there any obvious situations that I cannot immediately see? ...

C++ Representing a 3D array in a 1D array

I want to store the byte value of aFloat in pixelsArray for each 3D coordinate, in a 1D array: float aFloat = 1.0; unsigned char* pixelsArray = new unsigned char[HEIGHT*WIDTH*3]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { for (int k = 0; k < 3; k++) { pixelsArray[?] = aFloat; }...

'const Name &var' or 'const Name& var'?

Possible Duplicate: What makes more sense - char* string or char *string? Sorry if this is a silly question, I am new to these things :-) I am working on a C++ code base which uses the following reference conventions: const Name &var const Name& var As far as I'm aware, they mean the same thing. Which of these is either ...

cygwin1.dll missing when compiling c++ with g++

I'm using cygwin and when I'm compiling hello world with gcc somehow the compiler doesn't understand about using std namespaces (some of them are missing), but when I compile with g++ yes they work. But when I click on the helloworld.exe it says that cygwin1.dll is missing. Is there anything can I do? ...

How to line things up when outputting to a file in C++

New code.... #include <cstdlib> #include <iostream> #include <fstream> #include <iomanip> using namespace std; void gradeg (double & average, string & grade) { if (average >= 90) { grade = "A"; } else if ((average < 90) & (average >= 80)) { grade = "B"; } else...

How can I load a string based on resource identifier?

I'm reading an entry from the registry that comes out something like: @%SystemRoot%\\System32\\wscsvc.dll,-200 I need to actually load the string from the file. I found an article which describes how the number on the end behaves (negative == specific resource ID, positive == the nth resource in the file), but I'm confused as to how o...

Is Visual Studio 2010's unit testing feature usable for native C++ code?

It seems to be mainly tailored to .net code. ...

What is the size of a class?

Possible Duplicate: Empty class in C++ class Class1 { char c; }; class Class2 { }; What is the size of Class1 and Class2? In VC6, I got both 1. can someone explain this? ...

help with BitConverter!

I cannot get the BitConverter class to work. I get the error 'BitConverter' undeclared (first use this function). I have tried putting 'using System;' at the top of my code because I saw that in some examples online, but it then tells me that 'System' has not been declared. What am i missing? A #include file? ...

(C++) How to declare a stl list as extern?

I have: std::list<Particle> particles; std::list<Particle>::iterator particleit; in my main.cpp. I need to declare both of these as extern in one of my class files, but my compiler gives me some error about a missing '>' when I try the straightforward way. How would I go about fixing this? ...