Possible Duplicates:
Why doesn't Java have compound assignment versions of the conditional-and and conditional-or operators? (&&=, ||=)
Why does a &&= Operator not exist?
Today at work I wrote the following LOC (the real identities of b and b1 are confidential :)
b &&= b1; // meaning b = b && b1;
I stared at it for a co...
As of ICU 4.2.1, the only straight-forward way to set a UnicodeString to a C string is to construct a new UnicodeString with the data, and then set the desired string to the new one, thus allocating, copying, and deallocating data more than I'd like.
Is there a way to set a UnicodeString to a (null-terminated/length) C string without ha...
Hi!
I'm trying to wrap a unmanaged C++ DLL with managed C++ and I keep getting linking errors.
even though I include my library.lib in the project and include the correct header file.
This is the managed class:
#pragma once
#include "..\Terminal\Terminal.h"
public ref class ManagedTerminal
{
private:
Terminal * m_unTerminal;
pu...
I am reading strings in C++ using fread where I am reading and storing shortSiteText in siteNames_. siteNames_ is declared as std::vector<char*> siteNames_; I use siteNames_ in other functions but because shortSiteText is a pointer, when I call the delete command on it, the last entry in siteNames_ is changed. How do I prevent this?
fo...
Question I've been given at the job interview. I was close to the solution but did not solve it unfortunately.
Assume we have a sequence that contains N numbers of type long. And we know for sure that among this sequence each number does occur exactly n times except for the one number that occurs exactly m times (0 < m < n). How do we f...
I work as the Mac coder on a c++ application which I share with PC coders who use VS2008. When they make changes to a source file that requires an non-included header file they get no warnings, as most of their headers are in a precompiled header. What setting can they use to have them be warned that they failed to add the required inclu...
Hello!
I wish to know if it's possible in C++ to somehow handle the following situations:
Situation 1) (Easily handled)
class BasicFacility { }
template <typename U1, typename U2> class Facility : public BasicFacility { }
Suppose now that we want to have some compilation-time assertion and we want to check if the arbitrary type ty...
I am trying to just click on an item in a list of items in a listwidget.
I right clicked in my UI and went to the slot:
void main::listWidget_itemClicked(QListWidgetItem* item)
In there I can run commands ect... But I want the selected item that I click on to be set to a String... I tried using the CONNECT/SIGNAL route, but I came u...
I have a thread pool that is using shared mutexes from the boost library.
While the answers to my other question were helpful,
http://stackoverflow.com/questions/3896717/example-of-how-to-use-boost-upgradeable-mutexes
What I have realised that what I actually need is not to block if a shared lock or upgrade lock could not be obtained. ...
1) For convenience I have my entire program in a try block. This way I can throw an exception at any point in my code and know that it will be handled the same way. As the program becomes larger will this technique cause a hit in performance?
2) If objects are de-allocated when out of scope, why would throwing a temporary object be vali...
Hi all,
I'm trying to write a little program that will add mDNS CNAME aliases to my Linux device, so that it can be accessed via more than one "something.local." domain name.
This program's intended function is the same as the avahi-aliases Python script, but in order to avoid a Python dependency, I'm trying to implement it in C++ inst...
Hi - In GetPrivateProfileString, lpReturnedString returns the string value present in the key of a particular section of an ini file.
My question is that how will i know exactly, how much memory has to be allocated, rather than just allocation a large chunk prior to calling this function.
DWORD WINAPI GetPrivateProfileString(
__in ...
I need to come up with some code that checks if a given integer falls within the bounds of a range. (The range is represented by a pair of integers.)
So, given a range r defined as an std::pair<int, int>, and a test integer n, I want to say:
if (n >= r.first && n <= r.second)
The catch is, I need to use a std::less<int> comparison fu...
Hello, everyone.
I'm somewhat new to OpenCV and for some reason, I'm not managing to get CamShift to work in C++. First of all, if anyone has a working CamShift example using the C++ interface I would really appreciate it.
Second, I'm trying to adapt the C example to C++, just to get it to work. Nothing fancy, yet. Basically, what I'm ...
say there are 2 classes:
struct A{ int GetInt(){ return 10; } };
struct B{ int m; };
I want to use object of type A or B in following function
tempate< typename T >
int GetInt( const T & t )
{
//if it's A, I'll call: return t.GetInt();
//if its' B, I'll call: return t.m;
}
Now, because there are whole bunch of classes, some c...
Sample code for dll/pyd:
#include <boost/python.hpp>
#include <iostream>
class Base
{
public: Base() {}
public: int getValue() { return 1; }
};
typedef boost::shared_ptr<Base> BasePtr;
class ParentA : public Base
{
public: ParentA() : Base() {}
};
typedef boost::shared_ptr<ParentA> ParentAPtr;
class Collector
{
public: Collect...
Hi,
I need to emulate a paged file system in C++. Need to store multiple tuples in a page(block of a file) with a directory at the end of each page pointing to the offset of each tuple on the page. I also need to store variable length attributes in the tuples. Would using an STL container and serializing it to disk be the best way forwa...
If you have this generic function:
template<class type, class ret, class atype1, class atype2, class atype3>
ret call3(type *pClass, ret(type::* funcptr)(atype1, atype2, atype3), atype1 arg, atype2 arg2, atype3 arg3)
{
//do some stuff here
return (pClass->*funcptr)(arg, arg2, arg3);
}
and you do this:
class MyClass
{
public...
I have some legacy code that I have to wrap, and I have come across this declaration:
class Foo : Bar
{
// ...
};
This seems to compile under GCC. I know it's bad, but I can't change it. My question is, if no inheritance access specifier is present, how does the C++ compiler handle it?
...
I am trying to write a .oct function for Octave that, given a single sine wave value, between -1 and 1, and sine wave period, returns a sine wave vector of period length with the last value in the vector being the given sine wave value. My code so far is:
#include <octave/oct.h>
#include <octave/dColVector.h>
#include <math.h>
#define P...