I presume that the following will give me 10 volatile ints
volatile int foo[10];
However, I don't think the following will do the same thing.
volatile int* foo;
foo = malloc(sizeof(int)*10);
Please correct me if I am wrong about this and how I can have a volatile array of items using malloc.
Thanks.
...
I can specify an integer literal of type unsigned long as follows:
const unsigned long example = 9UL;
How do I do likewise for an unsigned char?
const unsigned char example = 9U?;
This is needed to avoid compiler warning:
unsigned char example2 = 0;
...
min(9U?, example2);
I'm hoping to avoid the verbose workaround I currently h...
This question is related to my last one. I am trying to solve the problem using traits<T> and traits<T*>. Please consider the following code.
template<typename T>
struct traits
{
typedef const T& const_reference;
};
template<typename T>
struct traits<T*>
{
typedef const T const_reference;
};
template<typename T>
class test
{...
I am trying to learn c++ but most of the tutorials and books I have read or looked up teaches you this...
(I am assuming like most tutorials, they are teaching in the beginning to code either in win32 console or CLR console. In either case the following does not work.)
#include <iostream>
int main( )
{
std::cout << "Hello World\n"...
I am having a very weird issue with templates. Getting an error error: ‘traits’ is not a template. I couldn't reproduce the issue on a sample test project. But it happens on my project (which is bigger than I can post here).
Anyway, following are the files and usages I have. Anyone have any idea about when this error occurs?
I have the...
int findLargest (ListNode *p)
// --------------------------------------------------------------------------
// Preconditions: list head pointer is passed as a parameter.
// Postconditions: returns the largest value in the linked list.
// --------------------------------------------------------------------------
{
if (p->item != NULL...
What are Iterators in C++?
...
The question is simple "Say we have an integer 1 <= n <= 12,How to use strftime to display January for '1',February for '2',March for '3' and so on ... ?"
...
Im trying to write up a 3DS Loader, which has an OpenGL rendering implementation for use in my generic rendering system.
The problem here is I have vertices indexed to one array, and texture coordinates indexed to another. I dont want to generate a new set of indexes and original vertices by checking each vertexes combination of coordin...
Hi :D
I'm writing a sound editor for my graduation. I'm using BASS to extract samples from MP3, WAV, OGG etc files and add DSP effects like echo, flanger etc. Simply speaching I made my framework that apply an effect from position1 to position2, cut/paste management.
Now my problem is that I want to create a control similar with this o...
What would be the simplest way for an application I'm writing to block all Internet access on a Windows machine?
More details:
Windows: XP or higher
Application: A basic Win32 app written in C/C++.
Blocking: It needs to be able to block and unblock at will, ideally in a way that the user can't easily reverse. (By, say, right clickin...
Consider the following C++ program, which takes a file and prints each line. It's a slice of a larger program where I later append to the file, based on what I see.
#include <fstream>
using std::fstream;
#include <iostream>
#include <string>
using std::string;
int main()
{
fstream file("file.txt", fstream::in | fstream::out | fstream:...
I am trying to implement Pollard Rho integer factorization in C/C++.Google gives me a Java implementation of the problem here.
I don't know Java that well,so what I came up with this.My implemenation in C++ works for most cases but not in few like the one "9999", I used there.
I am aware that C++ didn't have Biginteger class so I can't...
Lets say we create an object of class Student, we create two instances/objects class Student(i.e. StudentA and StudentB). We do shallow copy to initialize data members of B with that of A as follows:
Student StudentB = StudentA;
And then we destroy StudentB. Are we facing a situation of Dangling Pointer here? Why and how? Please explai...
What's the most idiomatic way to convert a set of integers into a set of ranges?
E.g. given the set {0, 1, 2, 3, 4, 7, 8, 9, 11} I want to get { {0,4}, {7,9}, {11,11} }.
Let's say we are converting from std::set<int> into std::vector<std::pair<int, int>>.
I treat Ranges as inclusive on both sides, since it's more convenient in my cas...
I'm having some problems with inheritance and constructors in C++. What I've got is a class VirtualMotor which inherits Motor (is that the correct way to say it?). The class VirtualMotor should have it's own constructor, but I'm doing something wrong when I create it and the compiler gives me an error (se below). My source code is like t...
I have an MFC application displaying images where I need to display the image in true-size i.e. the image should be rendered such that physical length of the object captured on the image should be same as the displayed length. For example, if I captured a object of 5 cm length the image should be displayed such that if I take a scale and...
I am learning how to work with std::vector and want to access its values and functions. I have a vector object inside another object called spectrum. Now when I try to determine the capacity of the vector using .capacity it works fine if I just declare the vector. But when I declare the vector inside another object, I get syntax errors.
...
I am asking about the static binding of the function in C++. What's the data type conversion rules for the function binding.
Suppose we have
void func(int x);
void func(long x);
void func(float x);
void func(double x);
void func(char x);
and I have one function in main
func(1)
I know the function func(int x) will be called. I am ...
What will happen if I use a inline function inside a virtual function? I'm confused with questions like
http://www.parashift.com/c++-faq-lite/value-vs-ref-semantics.html#faq-31.6
I can understand it, but is that mean, it will non-sense to use (call) inline functions inside virtual functions (please assume that it is calling dynamically...