I am using singletons as follows:
// Foo.hpp
class Foo {
static Foo* instance() {
static Foo* foo = new Foo();
return foo;
}
}
Now, my singleton is initialized the first time Foo::instance() is called. I want to make sure this is before main executes (my code is multi threaded, I want all singletons initialized before pThr...
I have a legacy data structure that's 672 bytes long. These structs are stored in a file, sequentially, and I need to read them in.
While I can read them in one-by-one, it would be nice to do this:
// I know in advance how many structs to read in
vector<MyStruct> bunchOfStructs;
bunchOfStructs.resize(numberOfStructs);
ifstream ifs;
if...
I've been seeking for JPG saving library for long time for c++, but i cant seem to get anything to work. Now i am trying use LibGD:
What im doing wrong ? It seems to work, but the saving crashes. Code:
...
#pragma comment(lib, "bgd.lib")
#include <gd/gd.h>
...
void save_test(){
gdImagePtr im;
FILE *jpegout;
int black;
...
I need to profile a real time C++ app on Windows. Most of the available profilers are either terribly expensive, total overkill, or both. I don't need any .NET stuff. Since it is a real time app, I need the profiler to be as fast as possible. It would be excellent if it integrated in some way with Visual Studio 2005/2008, but that's not ...
How can I export whole class to shared library?
Is it posible to use THIS library by other languages? ( pascal )
...
I have an issue that I can't seem to solve. I am randomly generating numbers in order to determine if my numbers are relativity prime.
Here is the function that gives me a Floating Point Exception:
bool modularExponentiationTest(unsigned long long exponent, unsigned long long modulus)
{
short index = 0;
unsigned long long base;...
I've recently been writing some code for a research project that I'm working on, where efficiency is very important. I've been considering scraping some of the regular methods I do things in and using bitwise XORs instead. What I'm wondering is if this will make if a difference (if I'm performing this operation say several million times)...
im somewhat new to c++ so i don't know how to do this but my main point in recoding this is to incress the speed of my program, i have been coding a project
and my code is:
HWND hWnd = FindWindow(NULL, L"*window's name*");
DWORD th32ProcId;
HANDLE hProc;
GetWindowThreadProcessId(hWnd, &th32ProcId);
hProc = OpenProcess(PROCESS_VM_OPERA...
Please read before answering. I dont want you to state the obvious for me. THANKS :D
I am trying to differentiate between pointers and passing by value. And I think I understand them but one thing the source I was reading wasnt clear on is what is the difference between passing a pointer and passing by value. consider the following...
...
How do I define a function inside of a class using C++?
...
I wrote this Node class and = operator overload function and this is the only way I could get it to compile and run but it just overflows and bomb my program. Can someone please fix it so it works. I don't have a lot of experience with overloading operator in C++. I just want to set a Node object equal to another Node object. Thanks in a...
I'm currently using ShellExecute "open" to open a URL in the user's browser, but running into a bit of trouble in Win7 and Vista because the program runs elevated as a service.
When ShellExecute opens the browser, it seems to read the "Local Admin" profile instead of the user's. So for example, if the user at the keyboard has Firefox a...
I've got way too much information to work with, so for now I'll consider this question answered until I can sort it all out and decide on the final implementation! Thanks a ton gf and Simon Buchan. I wish I could accept both of your answers, since they're both definite possibilities!
Additional / Revised Conceptual Information as sugges...
Please help I'm new to C++
Using stacks Implementation
I should read a sample text file containing:
text file
begining to end
return text
And return a text file reading:
return text
begining to end
test file
This is the sample code to test the implementation:
#include <iostream>
#include <fstream>
#include <string>
#include "sta...
how to define a "class" for "stock" using c++ language? The class should include the method of "meanvalue" and "variance", meanwhile it should also contain "trading volume" and some historical data. Thank you very much.
...
I want to construct an object in the stack, using C++.
Do you know what is the difference between these to ways of calling the constructor (with and without parenthesis):
a)
MyClass object ;
b)
MyClass object() ;
I am using MFC and when constructing the global variable for the main app, if I use the latter way, I get an exception, I...
I am learning about COM and reading about this code:
STDMETHODIMP_ (ULONG) ComCar::Release()
{
if(--m_refCount==0) delete this;
return m_refCount;
}
My question is, if the m_refCount==0 and the object is deleted, how could the instance member variable *m_refCount* still exist and be returned? Please forgive me if my questio...
Do static variables have the same or similar functionality in C# as they do in C++?
Edit:
With C++ you can use static variables in many different contexts - such as: 1) Global variables, 2) Local function variables, 3) Class members - Would similar usages in C# behave similar to that of C++?
...
I'm a programming student in my first C++ class, and recently we were encouraged to write a simple recursive function to find the first occurrence of a substring in a given string. If found, it returns the index. If the substring is not found, the index_of() function should return -1. We are encouraged to use a helper function that ta...