hi.
does vector::operator= change vector capacity? if so, how?
does copy constructor copy capacity?
I looked through documentation but could not find specific answer.
is it implementation dependent?
Thanks
How do you pronounce C++'s scope operator :: when you read it aloud? Do you just say "colon-colon", or do you say something wittier or more euphonious?
These questions are a kind of game, and I did not find the solution for them.
It is possible to write ::: in C++ without using quotes or anything like this and the compiler will accept it (macros are prohibited too).
And the same is true for C# too, but in C#, you have to write ???.
I think C++ will use the :: scope operator and C# will use ? : , but I do not know the answers to them.
Any idea?
I got asked this question once and still haven't been able to figure it out:
You have an array of N integers, where N is large, say, a billion. You want to calculate the median value of this array. Assume you have m+1 machines (m workers, one master) to distribute the job to. How would you go about doing this?
Since the median is a nonlinear operator, you can't just find the median in each machine and then take the median of those values.
Hi All,
in a pre-compiled header if I do:
#define DS_BUILD
#define PGE_BUILD
#define DEMO
then in source I do:
#if (DS_BUILD && DEMO)
---- code---
#elif (PGE_BUILD && DEMO)
--- code---
#else
--- code ---
#endif
Do I get an error that states: error: operator '&&' has no right operand
I have never seen this before. I am using XCode 3.2, GCC 4.2 on OS X 10.6.3
So I have these lines of code:
int maxY, maxX;
getmaxyx(stdscr, &maxY, &maxX);
It gives me the following error:
error C2440: '=' : cannot convert from 'int' to 'int *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
twice for each time I use it. I'm not even using the = operator! The curses.h file is included. What am I doing wrong?
Hi friends....
I have two tables.I want to get all records from one table that are different from the records in second table.
For eg.
if we have four records in first table like A,B,C,D and three records in second table thats A,B,C then the answer of query should be D.
I have tried "EXCEPT" operator but it doesnt work fine.Kindly help me in writing correct query for the given problem.
Any help is appreciated....
Thanks in Advance
Nemat
This question was inspired by What features would you like to see added to C++? (also see What features do you miss in C++?).
C++ is a great general-purpose language, but perhaps too general and feature-rich: multiple inheritance, operator overloading, manual memory management, templates, smart pointers, virtual destructors, legacy frameworks (think MFC), and I could go on.
Is there any one feature or aspect of C++ that you would like removed to make our lives easier as C++ developers?
One feature per answer, please.
I believe the expression T() creates an rvalue (by the Standard)
However the following code compiles (at least on gcc4.0)
class T {... };
int main()
{
T() = T();
}
I know technically this is possible because member functions can be invoked on temporaries and the above is just invoking the operator= on the r-value temporary created from T().
But conceptually this is like assigning a new value to an r-value.
Is there a good reason why this is allowed?
I have a homework assignment with a number of questions. One is asking why the strcpy() function doesn't need the call by reference operator for CStrings. I've looked through the book numerous times and I can't, for the life of me, find the answer. Can anyone help explain this to me?
It is an array of sorts so I would think you would need the call by reference.
If the value after the shift operator
is greater than the number of bits in
the left-hand operand, the result is
undefined. If the left-hand operand is
unsigned, the right shift is a logical
shift so the upper bits will be filled
with zeros. If the left-hand operand
is signed, the right shift may or may
not be a logical shift (that is, the
behavior is undefined).
Can somebody explain me what the above lines mean??
*we release and the acquire the pointer with the Linked_ptr in parameter
*/
Linked_ptr& operator=(const Linked_ptr& r)
{
if (this != &r) {
release();
acquire(r);
}
return *this;
}
What's going on when the assignment statement executed at Line 4, does compiler ignore the new operator and keep the foo variable being null or something else happen to handle this awkward moment?
public class Foo {
// creating an instance before its constructor has been invoked, suppose the "initializing"
// gets printed in constructor as a result of the next line, of course it will not print it
private Foo foo = new Foo();//Line 4
public Foo() {
System.out.println("initializing");
}
}
I'm trying make a lists difference. Found directly prelude operator \\\\ that makes lists difference. But errors Not in scope: '\\\\' occurs. Here is my simple from command line interpreter:
Prelude> ([1,2,3] ++ [5,6]) -- works like expected
[1,2,3,4,5,6]
prelude> ([1,2,3] \\\\ [1,2]) -- erros occurs
<interactive>:1:11: Not in scope: "\\\\"
Thanks for explanation where I make a mistake.
hello.
I have ran into yet another problem I do not understand.
The following does not instantiate, why?
template<class E>
void operator[](typename boost::mpl::identity<E>::type e) const;
thank you for your help
Hi, if I'm using the sizeof operator and making use of size_t in my code, do I have necessarily have to include the preprocessor directive stddef.h ? I haven't included the stddef.h and my code compiles without warning with both MVS2008 and with Borland C++ BuilderX.
Thanks a lot...
When you have a circular buffer represented as an array, and you need the index to wraparound (i.e., when you reach the highest possible index and increment it), is it "better" to:
return (i++ == buffer.length) ? 0: i;
Or
return i++ % buffer.length;
Has using the modulo operator any drawbacks? Is it less readable than the first solution?
Sounds like a "let me google it for you" question, but somehow I can't find an answer. The Lua # operator only counts entries with integer keys, and so does table.getn:
tbl = {}
tbl["test"] = 47
tbl[1] = 48
print(#tbl, table.getn(tbl)) -- prints "1 1"
count = 0
for _ in pairs(tbl) do count = count + 1 end
print count -- prints "2"
How do I get the number of all entries?
I have set new division on postgress pg_operator table because i want tath when is division by zero return 0.
i have write this:
create operator / ( procedure = zero_division, leftarg = double precision, rightarg = double precision);
where zero_division is:
CREATE OR REPLACE FUNCTION zero_division(double precision, double precision)
RETURNS double precision AS
'select case when $2 = 0 then 0 else $1 / $2::real end;'
LANGUAGE sql IMMUTABLE
COST 100;
when i run value/ 0 i get error of division.
Possible Duplicate:
Hidden Features of Java
Just want to know any hidden/very rarely used features of java which are not so dominant in coding.
Like i found the ?? operator in c#
I have a vector of custom Struct that needs to be sorted on different criteria each time
Implementing operator < will allow only one criteria
But I want to be able to specify sorting criteria each time I call C++ standard sort.
How to do that?
Please note it is better to be efficient in running time..
Thanks
I have an IPEndPoint a and b, whose IPAddress and Port are exactly the same, but the == operator is on the IPEndPoint not returning true. To make things even stranger, I tried to circumvent the problem by simply comparing the IPAddress and Port individually and it is STILL not returning true.
Has anyone encountered this before? If so, I am all ears to performant solutions. We have collections of as many as 10k IPEndPoints and are querying into them via LINQ (PLINQ pretty soon).
In mysql I am able to do this:
SELECT *
FROM table
WHERE auth_user.lastactivity > NOW() - 100
now in postgresql I am using this query:
SELECT *
FROM table
WHERE auth_user.lastactivity > CURRENT_TIMESTAMP - 100
but I get this error:
operator does not exist: timestamp with time zone - integer
How can I resolve ?
I'm trying to define my own operator in Io, and I'm having a hard time. I have an object:
MyObject := Object clone do(
lst := list()
!! := method(n, lst at(n))
)
But when I call it, like this:
x := MyObject clone do(lst appendSeq(list(1, 2, 3)))
x !! 2
But I get an exception that argument 0 to at must not be nil. How can I fix?
I currently allocate my memory for arrays using the MS specific mm_malloc. I align the memory, as I'm doing some heavy duty math and the vectorization takes advantage of the alignment. I was wondering if anyone knows how to overload the new operator to do the same thing, as I feel dirty malloc'ing everywhere (and would eventually like to also compile on Linux)? Thanks for any help