How can I call a function and keep my constructor private? If I make the class static, I need to declare an object name which the compiler uses to call the constructor, which it cannot if the constructor is private (also the object would be extraneous). Here is the code I am attempting to use (it is not compilable):
I want to keep the ...
I've gotten a crash in my program which seems fine to me, of course my program says otherwise, which confuses me.
This snippet of my function I am currently working on:
for(int k = 0; k < dictionary[k].size(); k++)
{
//"i" represents the fragment's first character
//while "k" represents the dicti...
What is the best way to enumerate all of the user profiles on a computer?
I know how to get the currently logged in user profile, and I know how to get the "all user" profile. But I'd like to get a list of each and every profile on the computer.
...
Hi,
Is it safe to use longjmp and setjmp in C++ on linux/gcc with regards to the following?
Exception handling (I'm not implementing exception handling using longjmp/setjmp. I want to know what side effects longjmp/setjmp will have on standard exception handling)
*this pointer
Signals
Smart pointers (boost's shared and intrusive point...
I am looking for some blog site where i will be able to directly paste c++ code examples
in my publishes and see the code with all the alignments and colors like i see it on pastie.org.
I need all those things be made automatically because i don't know HTML and can't make by myself the code changes.
...
why isnt my object being created?
When I do it like so, I am told error C2065: 'AllReferrals' : undeclared identifier
as well as error C2228: left of '.push_back' must have class/struct/union.
If I put the list initialization before the class I get error C2065: 'AllReferrals' : undeclared identifier.
Thanks!
#include <iostream>
#inclu...
I can't for the life of me figure out how to do this properly. I have a class that needs to store some constants (text that corresponds to values in an enum type) - I have it declared like this (publicly) in my class:
const static char* enumText[];
And I'm trying to initialize it like this:
const char* MyClass::enumText[] = { "A", "...
My brain farts a lot when it comes to hex. Some people are abidextrous and others are just plain right handed... well, kind of like that, I'm VERY base10 I guess.
Anyway... I'm trying to make some firmware more efficient. We have a function that's calculating a vehicle's speed based on some hex data it gets via the CANBUS. Right now I...
Hi all;
My C++ is a little rusty having worked in Java and C# for the last half dozen years. I've got a stupid little error that I just cannot figure out.
I've pared the code down as much as possible.
#include <list>
template<class T> class Subscriber
{
virtual void published( T t ) = 0;
};
template <class T> class PubSub
{
priva...
I've been trying to get the boost library working with Code::Blocks and am having some trouble.
When I first tried to get boost, all I did was download the latest zip file and extract it into the CodeBlocks folder. Then I set the compiler settings to look in the boost folder. This allowed me to compile, but not to link. I then read the ...
Hello guys,
My setup includes:
Windows Vista, Eclipse 3.5.0, and gdb, make, gcc 3.4.4, g++ 3.4.4 enabled through Cygwin, and environmental variable is already set.
My FIRST problem is that I can run and build an application like the information in Console:
**** Build of configuration Debug for project HelloWorld ****
make all <br />...
Here is some code that used to work with my code, but is having a problem now:
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstring>
using namespace std;
int main()
{
stringstream out;
out << 100;
cout << out.str();
}
I get just blank output. I just changed to snow leopard with Xcode 3.2.
...
Must be a simple answer but I am at a loss, here is the code that is returning an error. I have tried with and without the starting slash.
I won't know the full path, I want it to be relative from the exe, and that is the relative path. I tried escaping the slashes.
My problem is that i get "error opening file" when the file is there. ...
How can you get unbuffered output from cout, so that it instantly writes to the console without the need to flush (similar to cerr)?
I thought it could be done through rdbuf()->pubsetbuf, but this doesn't seem to work. The following code snippet below is supposed to immediately output to the console, and then wait a few seconds. But i...
Is there a way to indent/tab multiple lines in one action in the Codgear RAD Studio IDE?
I.e. I would like to be able to highlight multiple lines and indent them all by one tab simultaneously.
...
How can I add a new Executable in my XCode project?
Hi,
I add a .cpp file in my XCode project. And the xcode project compiles fine afterward.
#include <iostream>
using namespace std;
int main(int argc, char **argv) {
cout << "Starting main " << endl;
}
But how can I execute that main in my xcode project?
I assume I need to cre...
I'm trying to hold the screen on my output using the header file <iostream.h>, but I don't know any equivalent function to the getch() & clrscr() functions of <conio.h> in <iostream.h> or any other C++ library. Are there any such functions?
...
I have some C++ code that uses a very standard exception pattern:
try {
// some code that throws a std::exception
}
catch (std::exception &e) {
// handle the exception
}
The problem is that the exceptions are not being caught and I cannot figure out why.
The code compiles to a static library in OS X (via Xcode). The library is l...
I am developing an application, I have added a QToolBar object in that, and have added the QToolButton object on that, I have also connect the clicked() event with that but the problem is that the mouse click event don't work on QToolButton but when I bring focus on that using Tab, then space button works fine, but I want it with mouse c...
Hi, i am currently working on a C++ project where i have an abstract interface that is implemented later on. The interface also has a implemented method which my implementation doesn't override.
My problem is that when using my implementation, the compiler(MSVC) doesn't see the interface method. What causes this, and how can i resolve it...