Hello!
I have a few classes (heat, gas, contact, pressure) inheriting from a main one (sensor).
I have a need to store them in a vector<Sensor *> (part of the specification).
At some point in time, I need to call a function that indiscriminately stores those Sensor *. (also part of the specification, not open for discussion)
Somethi...
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <cstring>
void initialize(char[],int*);
void input(const char[] ,int&);
void print ( const char*,const int);
void growOlder (const char [], int* );
bool comparePeople(const char* ,const int*,const char*,const int*);
int main(){
char name1[25];
cha...
If I write a function like this:
void doMaybeNothing()
{
#ifndef IM_LAZY
doSomething();
#endif
}
Are modern compilers smart enough to detect a no-op function and optimize so that there are no cycles wasted? Or is there always a small performance impact?
...
Hi,
I'm looking for a control to edit rich text. These are my requirements:
Fast/lightweight
Support for bulleted/numbered lists
Colored text and highlighting
targeting Windows, but cross-platform would be a bonus
Fine control over undo/redo and easy way to monitor what parts of the documents have changed
All the other usual feature...
I need to render a simple texture mapped model as the output of a directshow source filter. The 3d rendering doesnt need to come from Direct3D, but that would be nice. OpenGL or any other provider would be fine assuming I can fit it into the context of the DirectShow source filter.
visual studio 2008 c++
...
I know how they work conceptually, but how are signals and slots implemented in the Qt framework? Qt Creator treats them as keywords, but are they simply a set of macros, or is a special pre-processor required before these source files can be compiled?
In other words, if I use Qt's signal/slot features in my code, can I easily compile ...
Can operator == be overloaded so as to compare 2 char[] using a string comparison.
...
I tried following code :
#include<iostream>
#include<string>
using namespace std;
string f1(string s)
{
return s="f1 called";
}
void f2(string *s)
{
cout<<*s<<endl;
}
int main()
{
string str;
f2(&f1(str));
}
But this code doesn't compile.
What I think is : f1 returns by value so it creates temporary, of which I am taki...
While i m using gmp.h header file. i need a fuction which takes inputs of type mpz_t and return mpz_t type too.
I m very beginner of using gmp.h
So, Here is snaps follows of my approached code....
mpz_t sum_upto(mpz_t max)
{
mpz_t sum;
mpz_init(sum);
mpz_init(result);
for(int i=0;i<=max-1;i++)
...
Can I declare a map like this
map<string, vector<string>> mymap;
I thought it is applicable.
However, it shows not.
I tried
map<string, vector<string>*> mymap;
and then it is OK
What's the rule of this?
...
GDI+ makes use of WCHAR instead of what the WinAPI allows which is CHAR. Usually I can do:
char *str = "C:/x.bmp";
but how do I do this for wchar? I can't juse do
wchar_t *file = "C:/x.bmp";
Thanks
...
I have been trying to set up OpenCV for the past few days with no results. I am using Windows 7 and VS C++ 2008 express edition. I have downloaded and installed OpenCV 2.1 and some of the examples work. I downloaded CMake and ran it to generate the VS project files and built all of them but there with several errors, and couldn't get ...
I am immediately placing this as a community wiki thing. I don't want to ask for help in programming yet or have even a specific question about programming, but rather the process and the resources needed to make such a game.
To put it simply: My college friend and I decided to give ourselves a really big challenge to further our skill...
I resize my window like this:
RECT clientRect;
GetClientRect(mainWindow,&clientRect);
glShadeModel(GL_SMOOTH);
MoveWindow(framehWnd,
toolWidth,
tabHeight,
((clientRect.right - clientRect.left) - toolWidth) - rightRemainder ,
(clientRect.bottom - clientRect.top) - tabHeight - paramHeight,
...
I've been having trouble with this for a while now, and I haven't gotten any solutions that work yet. Here is the problem, and the specifics:
I am loading a 256x256 uncompressed TGA into a simple OpenGL program that draws a quad on the screen, but when it shows up, it is shifted about two pixels to the left, with the cropped part appea...
Suppose I have a class A and a class B.
The .h of A, needs the .h of B, and the .h of B needs the .h of A. (need = #include).
All .h have the guards:
#ifndef _classX_
#define _classX_
...
...
#endif
But if I compile the .cpp of A, then when it includes the .h of B, the B class cannot include the .h of A class because the A class has...
void main()
{
int xyz = 123; // original value
{ // code block starts
xyz++;
if(xyz < 1000)
xyz = 1;
} // code block ends
int original_value = xyz; // should be 123
}
void main()
{
int xyz = 123; // original value
MACRO_NAME(xyz = 123) // the macro takes the code code that should be ex...
Hi, I'm new to C++ and I'm trying to figure out this problem I'm having with my constructor for one of my classes. What happens is... all my variables are initialized properly except two (health and type).
#pragma once
#include <irrlicht.h>
#include <vector>
#include <cassert>
using namespace irr;
using namespace core;
using namespace ...
Possible Duplicate:
When to use std::size_t?
I have a lot of constants in my code that are unsigned numbers, e.g. counters, frequency cutoffs, lengths, etc. I started using std::size_t for all of these, instead of int or unsigned int.
Is that the right thing to do? I started it because the STL containers use it for their siz...
Is there a easy standards-compliant way to check if a URL string is a valid format? Either through a specific URL-type class or maybe someone could show me how to do a regex validation of it?
...