vector < Shape* > shapes;
void createScene()
{
image = QImage(width, height, 32); // 32 Bit
Color amb(0.1,0.1,0.1);
Color difCoef(0.75,0.6,0.22);
Color spec(0.5,0.5,0.5);
double shine= 3.0;
Sphere *s = new Sphere(Point(0.0,0.0,-5), 100.0, amb, difCoef, spec, shine);
shapes.push_back(s);
}
int main(){
// initialize glut
i...
Is there an automatic way to optimize inclusion of header files in C++, so that compilation time is improved ? With the word "automatic" I mean a tool or program. Is it possible to find which headers files are obsolete (e.g exposed functionality is not used) ?
Edit: Having each include header "included only once is one important thing,...
I'd like to read/write some registry information from my non-admin Windows Service, and have it applied regardless of the user logged in. Would using a subkey of HKEY_USERS/.DEFAULT do the trick?
Essentially, something like CSIDL_COMMON_APPDATA but in the registry.
Thanks!
...
How can a program draw text on a frame buffer mapped in as an array? What is needed is both a means of representing the individual characters, and of drawing the characters pixel by pixel in a manner that is not too inefficient. The representation of the characters should ideally be defined solely in code, and no third party libraries wo...
I'm writing C++ using the MinGW GNU compiler and the problem occurs when I try to use an externally defined integer variable as a case in a switch statement. I get the following compiler error: "case label does not reduce to an integer constant".
Because I've defined the integer variable as extern I believe that it should compile, do...
I have a plist that is processed with a precompiled header file and in it there is the "variable" VERSION_STRING used a few times in such fields as CFBundleGetInfoString, ie the value for the key CFBundleGetInfoString is: MyProduct VERSION_STRING Copyright © 2009 MyCorp
In MyHeader.h (which is the set as the Info.plist prefix header I w...
Hi.
Studing STL I have written a a simple program to test functors and modifiers. My question is about the difference aon using CLASS or STRUCT to write a functor and try to operate on it with function adaptors.
As far as I understand in C++ the difference beetween CLASS and STRUCT is that in the last case the members are public by defau...
Hi,
I need an encryption scheme where the plaintext and ciphertext are composed entirely of decimal digits.
In addition, the plaintext and ciphertext must be the same length.
Also the underlying encryption algorithm should be an industry-standard.
I don't mind if its symmetric (e.g AES) or asymmetric (e.g RSA) - but it must be a recog...
My last question was a mess. I'm getting the wrong output.
So here I have in my main:
image = QImage(width, height, 32); // 32 Bit
Color amb(0.1,0.1,0.1);
Color difCoef(0.75,0.6,0.22);
Color spec(0.5,0.5,0.5);
double shineExp = 3.0;
Sphere *s = new Sphere(Point(0.0,0.0,-5), 100.0, amb, difCoef, spec, shineExp);
shapes.push_back(s);
W...
If I call a function like
myObj.setType("fluid");
many times in a program, how many copies of the literal "fluid" are saved in memory? Can the compiler recognize that this literal is already defined and just reference it again?
...
when i download a fresh copy from our SVN, make then run my program, Qt tells me that one of my SLOTS doesn't work but with a handy-dandy make clean then make, it seems to solve the problem. i continue to make changes in the code on my PC and that message never shows again.
C++
Qt 4.6
gcc
has anyone had this problem?
and ideas?
thanks...
Suppose Client A connects though TCP/IP Sockets to Server B
Is it possible to create a Proxy Like Server thing to do this:
Client A Connects to Proxy X ; And tried to authenticate to the server (sends authentication data) ; Proxy X receives those data and sends them to Server B and gets the response from the Server B and returns the res...
Reading some source code, I have found next traits definition:
namespace dds {
template <typename Topic> struct topic_type_support { };
template <typename Topic> struct topic_data_writer { };
template <typename Topic> struct topic_data_reader { };
template <typename Topic> struct topic_data_seq { };
}
#define REGISTER_TOP...
I have a vector like so:
vector<MyType*> _types;
And I want to iterate over the vector and call a function on each of MyTypes in the vector, but I'm getting invalid return errors from the compiler. It appears the pos iterator isn't a pointer to MyType, it's something else. What am I not understanding?
Edit: Some code..
for (pos =...
I have a makefile (using nmake & VC++ 2005):
CPP_OBJS = $(CPP_SOURCE:.cpp=.obj)
$(TARGET) : $(CPP_OBJS)
$(link) $(ldebug) $(lflags) /DLL \
$(LIBPATHS) \
$out:$@ $(CPP_OBJS) $(conlibs)
The problem is link step fails because $(CPP_OBJS) are expanded into the list of files where each filename is prepended with a folder name...
I'm wondering if a class's member function should be const if it calls other functions that modify its data members. A good example would be a public member function that uses private member functions to do the brunt of the work.
void Foo::Show() const { // Doesn't directly modify data members in this function
ShowPig(); // One or a...
I'd like to put an expiration date in some software I made. Obviously
psuedocode:
if time() > xxx: exit()
All someone has to do here is set their system clock back. Anything better to do?
...
I wrote a simple C++ program to illustrate my problem:
extern "C"{
int test(int, char*);
}
int test(int i, char* var){
if (i == 1){
strcpy(var,"hi");
}
return 1;
}
I compile this into an so. From python I call:
from ctypes import *
libso = CDLL("Debug/libctypesTest.so")
func = libso.test
func.res_type = c_int
...
I have two questions.
In C++, a static member function has direct access to a public non-static data member defined in the same class?
False
In C++, a non-static member function has direct access to a private static data member defined in the same class?
True
My note say false for the first question and true for the second one. I jus...
I wanna write a little c++ program using libcurl. It's for a school project so I need to be able to package everything in a zip file and email it to my instructor.
I've just downloaded the tar from the libcurl website but now I'm not sure what the next step is... What else do I gotta do in order to be able to do #include "curl/curl.h" an...