Search Results

Search found 3861 results on 155 pages for 'assignment operator'.

Page 10/155 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • C++ streams operator << and manipulators / formatters

    - by Ayman
    First, most of my recent work was Java. So even though I "know" C++, I do not want to write Java in C++. And C++ templates are one thing I will really miss when going back to Java. Now that this out of the way, if I want to do create a new stream formatter, say pic, that will have a single std::string parameter in it's constructor. I would like the user to be able to write something like: cout << pic("Date is 20../../..") << "100317" << endl; The output should be Date is 2010/03/17 How do I write the pic class? when the compiler sees the cout what are the underlying steps the compiler does?

    Read the article

  • SQL Logic Operator Precedence: And and Or

    - by nc
    Are the two statements below equivalent? SELECT [...] FROM [...] WHERE some_col in (1,2,3,4,5) AND some_other_expr and SELECT [...] FROM [...] WHERE some_col in (1,2,3) or some_col in (4,5) AND some_other_expr Is there some sort of truth table I could use to verify this? Thanks.

    Read the article

  • Linq2SQL to produce Like operator

    - by Dante
    Hi, I have a string "Word1 Word2" and I want to transform it to a query such as "Like '%Word1%Word2%'". At the moment I have: from t in Test where t.Field.Contains("Word1 Word2") How to do this in LINQ2SQL? Do I need to create two separate queries for this, can't I write it in the same statement? Thx in advance

    Read the article

  • LIKE operator with $variable

    - by skarama
    This is my first question here and I hope it is simple enough to get a quick answer! Basically, I have the following code: $variable = curPageURL(); $query = 'SELECT * FROM `tablename` WHERE `columnname` LIKE '$variable' ; If I echo the $variable, it prints the current page's url( which is a javascript on my page) Ultimately, what I want, is to be able to make a search for which the search-term is the current page's url, with wildcards before and after. I am not sure if this is possible at all, or if I simply have a syntax error, because I get no errors, simply no result! I tried : $query = 'SELECT * FROM `tablename` WHERE `columnname` LIKE '"echo $variable" ' ; But again, I'm probably missing or using a misplaced ' " ; etc. Please tell me what I'm doing wrong!

    Read the article

  • Conditional operator in if-statement?

    - by Pindatjuh
    I've written the following if-statement in Java: if(methodName.equals("set" + this.name) || isBoolean() ? methodName.equals("is" + this.name) : methodName.equals("get" + this.name)) { ... } Is this a good practice to write such expressions in if, to separate state from condition? And can this expression be simplified?

    Read the article

  • Ternary operator in if-statement?

    - by Pindatjuh
    I've written the following if-statement in Java: if(methodName.equals("set" + this.name) || isBoolean() ? methodName.equals("is" + this.name) : methodName.equals("get" + this.name)) { ... } Is this a good practice to write such expressions in if, to separate state from condition? And can this expression be simplified?

    Read the article

  • post increment operator java

    - by srandpersonia
    I can't make heads or tails of the following code from "java puzzlers" by joshua bloch. public class Test22{ public static void main(String args[]){ int j=0; for(int i=0;i<100;i++){ j=j++; } System.out.println(j); //prints 0 int a=0,b=0; a=b++; System.out.println(a); System.out.println(b); //prints 1 } } I can't get the part where j prints 0. According to the author, j=j++ is similar to temp=j; j=j+1; j=temp; But a=b++ makes b 1. So it should've evaluated like this, a=b b=b+1 By following the same logic, shouldn't j=j++ be evaluated as, j=j j=j+1 Where does the temp come into picture here? Any explanations would be much appreciated. << I'm breaking my head over this. ;) Thanks in advance.

    Read the article

  • The unary increment operator in pointer arithmetic

    - by RhymesWithDuck
    Hello, this is my first post. I have this function for reversing a string in C that I found. void reverse(char* c) { if (*c != 0) { reverse(c + 1); } printf("%c",*c); } It works fine but if I replace: reverse(c + 1); with: reverse(++c); the first character of the original string is truncated. My question is why would are the statements not equivalent in this instance? Thanks

    Read the article

  • Is Operator Overloading supported in C

    - by caramel23
    Today when I was reading about LCC(windows) compiler I find out it has the implemention for operator overloading . I'm puzzled because after a bit of googling , it has been confirm that operator overloading ain't support in standard C , but I read some people's comment mentioning LCC is ANSI-compliant . So my real question is , is LCC really standard C or it's just like objective-c , a C variant with object-oriented feature ?

    Read the article

  • Double Buffering for Game objects, what's a nice clean generic C++ way?

    - by Gary
    This is in C++. So, I'm starting from scratch writing a game engine for fun and learning from the ground up. One of the ideas I want to implement is to have game object state (a struct) be double-buffered. For instance, I can have subsystems updating the new game object data while a render thread is rendering from the old data by guaranteeing there is a consistent state stored within the game object (the data from last time). After rendering of old and updating of new is finished, I can swap buffers and do it again. Question is, what's a good forward-looking and generic OOP way to expose this to my classes while trying to hide implementation details as much as possible? Would like to know your thoughts and considerations. I was thinking operator overloading could be used, but how do I overload assign for a templated class's member within my buffer class? for instance, I think this is an example of what I want: doublebuffer<Vector3> data; data.x=5; //would write to the member x within the new buffer int a=data.x; //would read from the old buffer's x member data.x+=1; //I guess this shouldn't be allowed If this is possible, I could choose to enable or disable double-buffering structs without changing much code. This is what I was considering: template <class T> class doublebuffer{ T T1; T T2; T * current=T1; T * old=T2; public: doublebuffer(); ~doublebuffer(); void swap(); operator=()?... }; and a game object would be like this: struct MyObjectData{ int x; float afloat; } class MyObject: public Node { doublebuffer<MyObjectData> data; functions... } What I have right now is functions that return pointers to the old and new buffer, and I guess any classes that use them have to be aware of this. Is there a better way?

    Read the article

  • How do you pronounce the '...' operator

    - by Uri
    Now, in c++ '...' became a first class operator. In speech, how do you pronounce it? So far I've heard: dot dot dot triple dot ellipsis related: Is it OK to replace ... with ellipsis in writing? e.g. "The ellipsis operator expands the pack" EDIT (clarification): We are all aware that '...' as a punctuation mark is indeed called ellipsis. But in the context of C++ we don't pronounce the names of the punctuation mark. For example, the '&' operator, depends on the context is pronounced as 'and', 'bitwise and', 'address of', 'logical and' (when && is used), or 'reference'. It is rarely pronounced as 'ampersand'. In speeches, I've a feeling that 'dot dot dot' is used more often. For example: http://channel9.msdn.com/Events/GoingNative/GoingNative-2012/Variadic-Templates-are-Funadic (an excellent presentation about variadic templates). On the other hand, 'dot dot dot' is awkward hard to pronouce ('d' and 't' are both pronounce with the tongue). Can we pronounce it 'unpack'?

    Read the article

  • Distinct operator in Linq

    - by Jalpesh P. Vadgama
    Linq operator provides great flexibility and easy way of coding. Let’s again take one more example of distinct operator. As name suggest it will find the distinct elements from IEnumerable. Let’s take an example of array in console application and then we will again print array to see is it working or not. Below is the code for that. In this application I have integer array which contains duplicate elements and then I will apply distinct operator to this and then I will print again result of distinct operators to actually see whether its working or not. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Experiment { class Program { static void Main(string[] args) { int[] intArray = { 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5 }; var uniqueIntegers = intArray.Distinct(); foreach (var uInteger in uniqueIntegers) { Console.WriteLine(uInteger); } Console.ReadKey(); } } } Below is output as expected.. That’s cool..Stay tuned for more.. Happy programming. Technorati Tags: Linq,Distinct

    Read the article

  • Play music by Operator in asterisk?

    - by Rev
    Hi I want in call duration between operator and caller,play sound for operator(something like hold music). But in order to play this sound, operator must dial unique code and then sound will be play for caller, and caller only hear that sound file! After that (sound fully played), caller back to operator's queue or something like this. So is this possible to do or not? (if possible, post dial-plan for this too)

    Read the article

  • Play music by Operator in asterisk?

    - by Rev
    Hi I want in call duration between operator and caller,play sound for operator(something like hold music). But in order to play this sound, operator must dial unique code and then sound will be play for caller, and caller only hear that sound file! After that (sound fully played), caller back to operator's queue or something like this. So is this possible to do or not? (if possible, post dial-plan for this too)

    Read the article

  • C++ is there a difference between assignment inside a pass by value and pass by reference function?

    - by Rémy DAVID
    Is there a difference between foo and bar: class A { Object __o; void foo(Object& o) { __o = o; } void bar(Object o) { __o = o; } } As I understand it, foo performs no copy operation on object o when it is called, and one copy operation for assignment. Bar performs one copy operation on object o when it is called and another one for assignment. So I can more or less say that foo uses 2 times less memory than bar (if o is big enough). Is that correct ? Is it possible that the compiler optimises the bar function to perform only one copy operation on o ? i.e. makes __o pointing on the local copy of argument o instead of creating a new copy?

    Read the article

  • how to refer to the current struct in an overloaded operator?

    - by genesys
    Hi! I have a struct for which i want to define a relative order by defining < , , <= and = operators. actually in my order there won't be any equality, so if one struct is not smaller than another, it's automatically larger. I defined the first operator like this: struct MyStruct{ ... ... bool operator < (const MyStruct &b) const {return (somefancycomputation);} }; now i'd like to define the other operators based on this operator, such that <= will return the same as < and the other two will simply return the oposite. so for example for the operator i'd like to write something like bool operator > (const MyStruct &b) const {return !(self<b);} but i don't know how to refere to this 'self' since i can refere only to the fields inside the current struct. whole is in C++ hope my question was understandable :) thank you for the help!

    Read the article

  • Defining < for STL sort algorithm - operator overload, functor or standalone function?

    - by Andy
    I have a stl::list containing Widget class objects. They need to be sorted according to two members in the Widget class. For the sorting to work, I need to define a less-than comparator comparing two Widget objects. There seems to be a myriad of ways to do it. From what I can gather, one can either: a. Define a comparison operator overload in the class: bool Widget::operator< (const Widget &rhs) const b. Define a standalone function taking two Widgets: bool operator<(const Widget& lhs, const Widget& rhs); And then make the Widget class a friend of it: class Widget { // Various class definitions ... friend bool operator<(const Widget& lhs, const Widget& rhs); }; c. Define a functor and then include it as a parameter when calling the sort function: class Widget_Less : public binary_function<Widget, Widget, bool> { bool operator()(const Widget &lhs, const Widget& rhs) const; }; Does anybody know which method is better? In particular I am interested to know if I should do 1 or 2. I searched the book Effective STL by Scott Meyer but unfortunately it does not have anything to say about this. Thank you for your reply.

    Read the article

  • Move constructor and assignment operator: why no default for derived classes?

    - by doublep
    Why there is default move constructor or assignment operator not created for derived classes? To demonstrate what I mean; having this setup code: #include <utility> struct A { A () { } A (A&&) { throw 0; } A& operator= (A&&) { throw 0; } }; struct B : A { }; either of the following lines throws: A x (std::move (A ()); A x; x = A (); but neither of the following does: B x (std::move (B ()); B x; x = B (); In case it matters, I tested with GCC 4.4.

    Read the article

  • What is the purpose of Java's unary plus operator?

    - by Syntactic
    Java's unary plus operator appears to have come over from C, via C++. As near as I can tell, it has the following effects: promotes its operand to int, if it's not already an int or wider unboxes its operand, if it's a wrapper object complicates slightly the parsing of evil expressions containing large numbers of consecutive plus signs It seems to me that there are better (or, at least, clearer) ways to do all of these things. In this SO question, concerning the counterpart operator in C#, someone said that "It's there to be overloaded if you feel the need." But in Java, one cannot overload any operator. So does this operator exist in Java just because it existed in C++?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >