Consider following class
class test
{
public:
test(int x){ cout<< "test \n"; }
};
Now I want to create array of 50 objects of class test . I cannot change class test.
Objects can be created on heap or stack.
Creating objs on stack is not possible in this case since we dont have default constructor in class
test objs(1)[50]; /// Er...
If the locks make sure only one thread accesses the locked data at a time, then what controls access to the locking functions?
I thought that boost::mutex::scoped_lock should be at the beginning of each of my functions so the local variables don't get modified unexpectedly by another thread, is that correct? What if two threads are tryi...
I have made a new windows service which works fine using barebone code (just the basic framework for a service), however, when i link it against my dlls, lib file to use the functionality in the dll it crashes on start up with a 0xc0000034 error.
Is there a special place to put the dlls for a service or a special way to do this?
.
Edi...
I declare a static char array, then I pass it to a function. How to get the no. of bytes in the array inside the function?
...
Hi,
I have the following problem. I want to include a multi-line textfile as #define, i.e. what I need is a constant that stores the value of the text file. Example:
File 'f.txt': This\nis\n\nsome\ntext
and I want to initialize a constant (at compile time) in the style of
#define txtfile "This\nis\na\ntextfile"
where the string "Thi...
What are all the things one needs to be careful about when coding in a multicore environment?
For example, for a singleton class, it is better to create a global object and then return its reference than a static object.
i.e
Rather than having
MyClass & GetInstance()
{
static Myclass singleMyclass;
return singleMyclass;
}
It is be...
I have a class which has many small functons. By small functions, I mean functions that doesn't do any processing but just return a literal value. Something like
string Foo::method() const{
return "A";
}
I have created a header file "Foo.h" and source file "Foo.cpp". But since the function is very small, I am thinking about puttin...
Hi,
What do people here use C++ Abstract Base Class constructors for in the field? I am talking about pure interface classes having no data members and no non-pure virtual members.
Can anyone demonstrate any idioms which use ABC constructors in a useful way? Or is it just intrinsic to the nature of using ABCs to implement interfaces t...
In c (or maybe c++) , what's the difference between
char myarr[16]={0x00};
and
char myarr[16];
memset(myarr, '\0', sizeof(myarr));
??
edit: I ask this because in vc++ 2005 the result is the same..
edit more :
and
char myarr[16]={0x00,}; ?
maybe can get more comprehensive answer and not ambigous as some answers below re...
Without the following:
ATL
MFC
Question:
How to get the COM Server, to report back to the COM Client, once a particular event has terminated?
Regards
...
When I design classes and have to choose between inheritance and composition, I usually use the rule of thumb: if the relationship is "is-a" - use inheritance, and if the relationship is "has-a" - use composition.
Is it always right?
Thank you.
...
Hi,
In C++, I have a map<string, string>, containing an unknown number of entries. How can I pass this to a Lua function, so that the Lua function can use the data as a table?
Hugo
...
Which is the fastest algorithm to find out prime numbers using C++? I have used sieve's algorithm but I still want it to be faster!
...
Using a DB with C++ is a real mess and it was refreshing when I moved to Java to be able to use a unified system to abstract the whole layer away (aka Hibernate).
There are a couple of C++ abstract layers for DB's out there but they are usually vendor specific and only a thin layer that wraps the real C API. Has anybody come across some...
Without:
ATL
MFC
Note:
Client is executing in a different thread to that of the server
Question:
How do I control the behaviour of the client, once an event notification is received from the COM object (Server)?
How to implement an event interface from client?
Illustration below:
hresult = pis8->QueryInterface(
...
Hi,
I've written explorer bars (band object) before and AFAIK vertical explorer bars can only be on the left side. However, I was amazed when I saw this explorer bar by HP that is docked on the right hand side instead:
I've searched up google for a bit and I can't find any resources on this. Does anyone know how to build a vertical r...
I am planning to start an application which converts the speech to text in Linux.
Are there any existing interfaces so that I can extend them?
or Is there any such existing application in Linux?
Any inputs on this?
EDIT: The application that I am planning to write should be able convert every word that we speak to text, not just the Yes...
I've heard many people saying that if the number of elements expected in the container is relatively small it is better to use std::vector instead of std::map eventhough I use the container for only lookup and not for iterating. What is the real reason behind this ? Obviously the lookup performance of map can not be worse than that of th...
I know this is a darn simple question, but I'm very used to using Borland and wrappers, so this is a bit of a new approach for me. Can someone simply tell me how I Can open an OpenDialog that only gets .obj files from a visual studio c++ console app?
It's very much appreciated!
...
I'm writing a system that allows python scripts to be executed within a C++ application.
The python scripts are used to modify values within arrays of data (typically 2048x2048x4 arrays of floats)
I'm currently using numpy arrays created using the array API and registered with Python.
In the python scripts I'm accessing the arrays l...