Search Results

Search found 4493 results on 180 pages for 'operator keyword'.

Page 1/180 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Why friend overloaded operator is preferred to conversion operator in this case

    - by skydoor
    Hi I have a code like this, I think both the friend overloaded operator and conversion operator have the similar function. However, why does the friend overloaded operator is called in this case? What's the rules? Thanks so much! class A{ double i; public: A(int i):i(i) {} operator double () const { cout<<"conversion operator"<<endl;return i;} // a conversion operator friend bool operator>(int i, A a); // a friend funcion of operator > }; bool operator>(int i, A a ){ cout<<"Friend"<<endl; return i>a.i; } int main() { A aa(1); if (0 > aa){ return 1; } }

    Read the article

  • Keyword Selector Tools - Choosing the Best Tool For Your Keyword Research

    Keyword selector tools are crucial in being able to locate keywords and keyword phrases which, if used wisely, will increase traffic to a site. Increased traffic generally means increased profits so it is important to pick the keyword research tool that best suits your needs. However the choice of tools is vast. Some are free, some cost a one off fee whilst others require a monthly subscription. This article gives tips and ideas to consider when choosing a keyword selector tool.

    Read the article

  • Shortcut "or-assignment" (|=) operator in Java

    - by Dr. Monkey
    I have a long set of comparisons to do in Java, and I'd like to know if one or more of them come out as true. The string of comparisons was long and difficult to read, so I broke it up for readability, and automatically went to use a shortcut operator |= rather than negativeValue = negativeValue || boolean. boolean negativeValue = false; negativeValue |= (defaultStock < 0); negativeValue |= (defaultWholesale < 0); negativeValue |= (defaultRetail < 0); negativeValue |= (defaultDelivery < 0); I expect negativeValue to be true if any of the default<something> values are negative. Is this valid? Will it do what I expect? I couldn't see it mentioned on Sun's site or stackoverflow, but Eclipse doesn't seem to have a problem with it and the code compiles and runs.

    Read the article

  • C# Operator Overloading post-fix increment

    - by Victor
    I'm coding a date class and am having trouble with the post-fix increment (the prefix increment seems fine). Here is the sample code: public class date { int year, month, day; public date(int d, int m, int y) { day = d; month = m; year = y; } static public date operator ++(date d) { return d.Next(d); } } The method "Next(date d)" takes a date and returns tomorrows date (I left it out for brevity). I'm to young in C# to understand why the prefix is fine but postfix increment does nothing. But remember in C++ we would have to have two methods instead of just one - for prefix and postfix increments. Also no errors or warnings on compile.

    Read the article

  • How can I build pyv8 from source on FreeBSD against the v8 port?

    - by Utkonos
    I am unable to build pyv8 from source on FreeBSD. I have installed the /usr/ports/lang/v8 port, and I'm running into the following error. It seems that pyv8 wants to build v8 itself even though v8 is already built and installed. How can I point pyv8 to the already installed location of v8? # python setup.py build Found Google v8 base on V8_HOME , update it to the latest SVN trunk at running build ==================== INFO: Installing or updating GYP... -------------------- INFO: Check out GYP from SVN ... DEBUG: make dependencies ERROR: Check out GYP from SVN failed: code=2 DEBUG: "Makefile", line 43: Missing dependency operator "Makefile", line 45: Need an operator "Makefile", line 46: Need an operator "Makefile", line 48: Need an operator "Makefile", line 50: Need an operator "Makefile", line 52: Need an operator "Makefile", line 54: Missing dependency operator "Makefile", line 56: Need an operator "Makefile", line 58: Missing dependency operator "Makefile", line 60: Need an operator "Makefile", line 62: Missing dependency operator "Makefile", line 64: Need an operator "Makefile", line 66: Missing dependency operator "Makefile", line 68: Need an operator "Makefile", line 70: Missing dependency operator "Makefile", line 72: Need an operator "Makefile", line 73: Missing dependency operator "Makefile", line 75: Need an operator "Makefile", line 77: Missing dependency operator "Makefile", line 79: Need an operator "Makefile", line 81: Missing dependency operator "Makefile", line 83: Need an operator "Makefile", line 85: Missing dependency operator "Makefile", line 87: Need an operator "Makefile", line 89: Need an operator "Makefile", line 91: Missing dependency operator "Makefile", line 93: Need an operator "Makefile", line 95: Need an operator "Makefile", line 97: Need an operator "Makefile", line 99: Missing dependency operator "Makefile", line 101: Need an operator "Makefile", line 103: Missing dependency operator "Makefile", line 105: Need an operator "Makefile", line 107: Missing dependency operator "Makefile", line 109: Need an operator "Makefile", line 111: Missing dependency operator "Makefile", line 113: Need an operator "Makefile", line 115: Missing dependency operator "Makefile", line 117: Need an operator Error expanding embedded variable. ==================== INFO: Patching the GYP scripts INFO: patch the Google v8 build/standalone.gypi file to enable RTTI and C++ Exceptions ==================== INFO: building Google v8 with GYP for x64 platform with release mode -------------------- INFO: build v8 from SVN ... DEBUG: make verifyheap=off component=shared_library visibility=on gdbjit=off liveobjectlist=off regexp=native disassembler=off objectprint=off debuggersupport=on extrachecks=off snapshot=on werror=on x64.release ERROR: build v8 from SVN failed: code=2 DEBUG: "Makefile", line 43: Missing dependency operator "Makefile", line 45: Need an operator "Makefile", line 46: Need an operator "Makefile", line 48: Need an operator "Makefile", line 50: Need an operator "Makefile", line 52: Need an operator "Makefile", line 54: Missing dependency operator "Makefile", line 56: Need an operator "Makefile", line 58: Missing dependency operator "Makefile", line 60: Need an operator "Makefile", line 62: Missing dependency operator "Makefile", line 64: Need an operator "Makefile", line 66: Missing dependency operator "Makefile", line 68: Need an operator "Makefile", line 70: Missing dependency operator "Makefile", line 72: Need an operator "Makefile", line 73: Missing dependency operator "Makefile", line 75: Need an operator "Makefile", line 77: Missing dependency operator "Makefile", line 79: Need an operator "Makefile", line 81: Missing dependency operator "Makefile", line 83: Need an operator "Makefile", line 85: Missing dependency operator "Makefile", line 87: Need an operator "Makefile", line 89: Need an operator "Makefile", line 91: Missing dependency operator "Makefile", line 93: Need an operator "Makefile", line 95: Need an operator "Makefile", line 97: Need an operator "Makefile", line 99: Missing dependency operator "Makefile", line 101: Need an operator "Makefile", line 103: Missing dependency operator "Makefile", line 105: Need an operator "Makefile", line 107: Missing dependency operator "Makefile", line 109: Need an operator "Makefile", line 111: Missing dependency operator "Makefile", line 113: Need an operator "Makefile", line 115: Missing dependency operator "Makefile", line 117: Need an operator Error expanding embedded variable. The files that are installed by the v8 port are the following (in /usr/local): bin/d8 include/v8.h include/v8-debug.h include/v8-preparser.h include/v8-profiler.h include/v8-testing.h include/v8stdint.h lib/libv8.so lib/libv8.so.1

    Read the article

  • Working with operator[] and operator=

    - by calebthorne
    Given a simple class that overloads the '[ ]' operator: class A { public: int operator[](int p_index) { return a[p_index]; } private: int a[5]; }; I would like to accomplish the following: void main() { A Aobject; Aobject[0] = 1; // Problem here } How can I overload the assignment '=' operator in this case to work with the '[ ]' operator?

    Read the article

  • new and delete operator overloading

    - by Angus
    I am writing a simple program to understand the new and delete operator overloading. How is the size parameter passed into the new operator? For reference, here is my code: #include<iostream> #include<stdlib.h> #include<malloc.h> using namespace std; class loc{ private: int longitude,latitude; public: loc(){ longitude = latitude = 0; } loc(int lg,int lt){ longitude -= lg; latitude -= lt; } void show(){ cout << "longitude" << endl; cout << "latitude" << endl; } void* operator new(size_t size); void operator delete(void* p); void* operator new[](size_t size); void operator delete[](void* p); }; void* loc :: operator new(size_t size){ void* p; cout << "In overloaded new" << endl; p = malloc(size); cout << "size :" << size << endl; if(!p){ bad_alloc ba; throw ba; } return p; } void loc :: operator delete(void* p){ cout << "In delete operator" << endl; free(p); } void* loc :: operator new[](size_t size){ void* p; cout << "In overloaded new[]" << endl; p = malloc(size); cout << "size :" << size << endl; if(!p){ bad_alloc ba; throw ba; } return p; } void loc :: operator delete[](void* p){ cout << "In delete operator - array" << endl; free(p); } int main(){ loc *p1,*p2; int i; cout << "sizeof(loc)" << sizeof(loc) << endl; try{ p1 = new loc(10,20); } catch (bad_alloc ba){ cout << "Allocation error for p1" << endl; return 1; } try{ p2 = new loc[10]; } catch(bad_alloc ba){ cout << "Allocation error for p2" << endl; return 1; } p1->show(); for(i = 0;i < 10;i++){ p2[i].show(); } delete p1; delete[] p2; return 0; }

    Read the article

  • Keyword Research - Introducing Keyword Research

    What is keyword research? Let us start by saying that keywords are the words and phrases that people type into search engine search boxes to get information to solve their problems or to find out information about their interests. Keyword research is the art of finding out what these keywords are so that you can optimize your marketing or websites for them to get some of the search traffic from these search engines. The better your keyword research is the better as you can optimize your website or marketing to find those hungry buyers for your products and/or services.

    Read the article

  • Can operator<< in derived class call another operator<< in base class in c++?

    - by ivory
    In my code, Manager is derived from Employee and each of them have an operator<< override. class Employee{ protected: int salary; int rank; public: int getSalary()const{return salary;} int getRank()const{return rank;} Employee(int s, int r):salary(s), rank(r){}; }; ostream& operator<< (ostream& out, Employee& e){ out << "Salary: " << e.getSalary() << " Rank: " << e.getRank() << endl; return out; } class Manager: public Employee{ public: Manager(int s, int r): Employee(s, r){}; }; ostream& operator<< (ostream& out, Manager& m){ out << "Manager: "; cout << (Employee)m << endl; //can not compile, how to call function of Employee? return out; } I hoped cout << (Employee)m << endl; would call ostream& operator<< (ostream& out, Employee& e), but it failed.

    Read the article

  • Unique ways to use the Null Coalescing operator

    - by Atomiton
    I know the standard way of using the Null coalescing operator in C# is to set default values. string nobody = null; string somebody = "Bob Saget"; string anybody = ""; anybody = nobody ?? "Mr. T"; // returns Mr. T anybody = somebody ?? "Mr. T"; // returns "Bob Saget" But what else can ?? be used for? It doesn't seem as useful as the ternary operator, apart from being more concise and easier to read than: nobody = null; anybody = nobody == null ? "Bob Saget" : nobody; // returns Bob Saget So given that fewer even know about null coalescing operator... Have you used ?? for something else? Is ?? necessary, or should you just use the ternary operator (that most are familiar with)

    Read the article

  • C++: call original definition of operator equals

    - by Luis Daniel
    I am overloading the operator equals (==) as show bellow: #include <string> #include <algorithm> bool operator == (std::string str1, std::string str2) { std::transform(str1.begin(), str1.end(), str1.begin(), ::tolower); std::transform(str2.begin(), str2.end(), str2.begin(), ::tolower); return (str1 == str2); } but, the problem appear on line return (str1 == str2), because operator == is called recursively. So, how can I call the original definition for operator equals (not the overloaded) ? Best regards

    Read the article

  • Null-coalescing operator and operator && in C#

    - by abatishchev
    Is it possible to use together any way operator ?? and operator && in next case: bool? Any { get { var any = this.ViewState["any"] as bool?; return any.HasValue ? any.Value && this.SomeBool : any; } } This means next: if any is null then this.Any.HasValue return false if any has value, then it returns value considering another boolean property, i.e. Any && SomeBool

    Read the article

  • Create Keyword Object Perl Microsoft::AdCenter

    - by toobsco42
    So I looked at the perldoc for the Microsoft::AdCenter module and it shows this as an example of how to create a keyword object: ~$ perldoc Microsoft::AdCenter #Create a Keyword object my $keyword = Microsoft::AdCenter::V7::CampaignManagementService::Keyword->new ->Text("some text") ->BroadMatchBid(Microsoft::AdCenter::V7::CampaignManagementService::Bid->new->Amount(0.1)) ->ExactMatchBid(Microsoft::AdCenter::V7::CampaignManagementService::Bid->new->Amount(0.1)); However, doesn't this violate the new policy of using only one match type per keyword? Campaign Management changes: "Previously, you would create a single Keyword object and specify a bid value for each match that you wanted to bid on (for example, exact match or phrase match). If you did not specify a bid value at the keyword-level, adCenter used the default bid value specified at the ad group level. Now, you must create a Keyword object for each match type that you want to bid on. For example, to bid on the keyword car by using exact match and phrase match, create a Keyword object and set the Text element to car and the ExactMatchBid element to a bid amount. Then, create a second Keyword object and set the Text element to car and PhraseMatchBid to a bid amount. When you add the keywords, you’ll get a unique keyword ID for each keyword and match-type combination."

    Read the article

  • Operator Overloading in C++ as int + obj

    - by Azher
    Hi Guys, I have following class:- class myclass { size_t st; myclass(size_t pst) { st=pst; } operator int() { return (int)st; } int operator+(int intojb) { return int(st) + intobj; } }; this works fine as long as I use it like this:- char* src="This is test string"; int i= myclass(strlen(src)) + 100; but I am unable to do this:- int i= 100+ myclass(strlen(src)); Any idea, how can I achieve this?? Thanks in advance. Regards,

    Read the article

  • Implementing operator< in C++

    - by Vulcan Eager
    I have a class with a few numeric fields such as: class Class1 { int a; int b; int c; public: // constructor and so on... bool operator<(const Class1& other) const; }; I need to use objects of this class as a key in an std::map. I therefore implement operator<. What is the simplest implementation of operator< to use here?

    Read the article

  • The ternary (conditional) operator in C

    - by Bongali Babu
    What is the need for the conditional operator? Functionally it is redundant, since it implements an if-else construct. If the conditional operator is more efficient than the equivalent if-else assignment, why can't if-else be interpreted more efficiently by the compiler?

    Read the article

  • Overloading assignment operator in C++

    - by jasonline
    As I've understand, when overloading operator=, the return value should should be a non-const reference. A& A::operator=( const A& ) { // check for self-assignment, do assignment return *this; } It is non-const to allow non-const member functions to be called in cases like: ( a = b ).f(); But why should it return a reference? In what instance will it give a problem if the return value is not declared a reference, let's say return by value?

    Read the article

  • Why does operator<< not work with something returned by operator-?

    - by Felix
    Here's a small test program I wrote: #include <iostream> using namespace std; class A { public: int val; A(int _val=0):val(_val) { } A operator+(A &a) { return A(val + a.val); } A operator-(A &a) { return A(val - a.val); } friend ostream& operator<<(ostream &, A &); }; ostream& operator<<(ostream &out, A &a) { out<<a.val; return out; } int main() { A a(3), b(4), c = b - a; cout<<c<<endl; // this works cout<<(b-a)<<endl; // this doesn't return 0; } I can't seem to get why the line marked "this works" works and the one marked "this doesn't" doesn't. When I try to compile the program with the cout<<(b-a); line, here's what I get: [felix@the-machine C]$ g++ test.cpp test.cpp: In function ‘int main()’: test.cpp:26:13: error: no match for ‘operator<<’ in ‘std::cout << b.A::operator-(((A&)(& a)))’ /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:108:7: note: candidates are: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:117:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>, std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:127:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:165:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:169:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:173:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/bits/ostream.tcc:91:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:180:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/bits/ostream.tcc:105:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:191:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:200:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:204:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:209:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:213:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:221:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:225:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/bits/ostream.tcc:119:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>] test.cpp:18:11: note: std::ostream& operator<<(std::ostream&, A&) [felix@the-machine C]$ Quite nasty.

    Read the article

  • A Great Keyword Research Tip - How to Do the Right Keyword Research

    There are many different kinds of affiliate marketing advice being thrown out by different Internet marketing experts. They claim that it will lead to affiliate success. Most will say that an appropriate website for a certain target market would do the trick. The usual barometer, of course, is the Google ranking (these show the website traffic)-however, these hardly translate to a high amount of sales.

    Read the article

  • C# Conditional Operator Not a Statement?

    - by abelenky
    I have a simple little code fragment that is frustrating me: HashSet<long> groupUIDs = new HashSet<long>(); groupUIDs.Add(uid)? unique++ : dupes++; At compile time, it generates the error: Only assignment, call, increment, decrement, and new object expressions can be used as a statement HashSet.Add is documented to return a bool, so the ternary (?) operator should work, and this looks like a completely legitimate way to track the number of unique and duplicate items I add to a hash-set. When I reformat it as a if-then-else, it works fine. Can anyone explain the error, and if there is a way to do this as a simple ternary operator?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >