Hi - as I said, a complete beginner question here. I'm currently working my way through "Accelerated C++" and just came across this in chapter 3:
// invariant:
// we have read count grades so far, and
// sum is the sum of the first count grades
while (cin >> x) {
++count;
sum += x;
}
The authors follow this by explaining t...
Assume this code:
static inline void inc(int64_t* atomic)
{
__asm__ __volatile__
(
"lock incq %0\n"
: "=m" (*atomic)
: "m" (*atomic)
);
}
The Clang compiler doesn't support the lock prefix (yet?). What shall I do now?
...
I am a brand new programming student, so please forgive my ignorance. My assignment states:
Write a program that declares an array of 10 integers. Write a loop that accepts 10 values from the keyboard and write another loop that displays the 10 values. Do not use any subscripts within the two loops; use pointers only.
Here is my code:
...
I use Doxygen's triple-slash syntax to markup my C++ code. There are
two important cases which arise:
1) block markup comments which are the sole element on the line and may
or may not begin flush left; e.g.
class foo
/// A one sentence brief description of foo. The elaboration can
/// continue on for many lines.
{
...
};
voi...
I wish c++, was a little more specific on the messages they give. The following error is being thrown in the document below
main.h
#ifndef main_h
#define main_h
//includes
#include <windows.h>
#include <commctrl.h>
#include <d3d9.h>
#include <fstream>
#include "capplication.h"
//constants
#define TITLE "D3D Tut 01: Creat...
I need to store a 30 letter combination, but each letter can only be "0", "1" or "2". When I use sizeof(myString), it returns 32.
I want to use this 30 letter combination to access a row of an array, so I'm wondering if it is possible to use a 3 value bool of some sort to store 1 of 3 values in.
...
I have a IWebBrowser2 I use to visit some webpages with .Navigate()
When the page has a js error I got a warning box for "Syntax error", so I used .put_Silent(TRUE). And now I get a warning for "VS Just-In-Time Debugger: Unhandled exception" instead
How can I disable all the script error warnings (including JIT debugger) from my code (i...
Is there any way to check if a given function is declared with C-linkage (that is, with extern "C") at compile-time?
I am developing a plugin system. Each plugin can supply factory functions to the plugin-loading code. However, this has to be done via name (and subsequent use of GetProcAddress or dlsym). This requires that the functions...
Hi,
I want to use the contents of a vector of D3DXMatrices to my shader.
m_pLightMatrices->SetMatrixArray(¤tLightMatrices[0].m[0][0],0,numLights);
As we know the internals of a vector this poses no problems (as it is just a dynamic array).
Now when I access this matrix in hlsl to fill up a struct I get this strange behavior:
...
Does VC++ 2010 have support for C++0x's portable atomic type template?
...
I am trying to apply a texture onto my 3d cube but it is not showing up correctly. I believe that it might some what be working because the cube is all brown which is almost the same complexion as the texture. And I did not originally make the cube brown. These are the steps I've done to add the texture
I first declared 2 new varibles
...
Hello,
I'm trying to achieve a motion blur effect in my OpenGL application.
I read somewhere this solution, using the accumulation buffer:
glAccum(GL_MULT, 0.90);
glAccum(GL_ACCUM, 0.10);
glAccum(GL_RETURN, 1.0);
glFlush();
at the end of the rendering loop.
But nothing happens... What am I missing ?
Additions after genpfault ...
There is a list for GCC; is there a similar list for Visual Studio 2010?
...
This question came about as a result of some mixed-language programming. I had a Fortran routine I wanted to call from C++ code. Fortran passes all its parameters by reference (unless you tell it otherwise).
So I thought I'd be clever (bad start right there) in my C++ code and define the Fortran routine something like this:
extern "C" ...
Hi,
How to create in C++ an abstract class with some abstract methods that I want to override in a subclass? How should the .h file look? Is there a .cpp, if so how should it look?
In Java it would look like this:
abstract class GameObject
{
public abstract void update();
public abstract void paint(Graphics g);
}
class Player...
What I want to do: run some prerequisite code whenever instance of the class is going to be used inside a program. This code will check for requiremts etc. and should be run only once.
I found that this can be achieved using another object as static variable inside a constructor. Here's an example for a better picture:
class Prerequisi...
I know the difference between the member operator (.) and the member by pointer operator (->).
Why did the C designers create a different operator for this access? Why can't the compiler figure it out on its own?
If you always used a . does any case exist where it is ambiguous whether you mean a member or a member by pointer?
edit: I'...
hello.
Is there macro, something like BOOST_AUTO, which would allow to emulate automatic return type deduction of function in C++?
I mean something like trailing-return-type, http://en.wikipedia.org/wiki/C%2B%2B0x#Alternative_function_syntax
this is what I have:
using namespace boost::fusion;
#define AS_VECTOR(var, expr) BOOST_AUTO(v...
I am trying to learn and understand name mangling in C++. Here are some questions:
(1) From devx
When a global function is overloaded, the generated mangled name for each overloaded version is unique. Name mangling is also applied to variables. Thus, a local variable and a global variable with the same user-given name still get dist...
I'm trying to build a simple form in a c++ win32 console application.
instead of using cin and keep prompting the user to enter the details, i would like to display the form labels then using the tab key, allow the user to tab through.
What is the simplest way of doing this, without having to use ncurses?
all I need is cout the below a...