Search Results

Search found 17501 results on 701 pages for 'stored functions'.

Page 28/701 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • Implement two functions with the same name but different, non-covariant return types due to multiple abstract base classes

    - by user1508167
    If I have two abstract classes defining a pure virtual function with the same name, but different, non-covariant return types, how can I derive from these and define an implementation for both their functions? #include <iostream> class ITestA { public: virtual ~ITestA() {}; virtual float test() =0; }; class ITestB { public: virtual ~ITestB() {}; virtual bool test() =0; }; class C : public ITestA, public ITestB { public: /* Somehow implement ITestA::test and ITestB::test */ }; int main() { ITestA *a = new C(); std::cout << a->test() << std::endl; // should print a float, like "3.14" ITestB *b = dynamic_cast<ITestB *>(a); if (b) { std::cout << b->test() << std::endl; // should print "1" or "0" } delete(a); return 0; } As long as I don't call C::test() directly there's nothing ambiguous, so I think that it should work somehow and I guess I just didn't find the right notation yet. Or is this impossible, if so: Why?

    Read the article

  • What triggered the popularity of lambda functions in modern mainstream programming languages?

    - by Giorgio
    In the last few years anonymous functions (AKA lambda functions) have become a very popular language construct and almost every major / mainstream programming language has introduced them or is planned to introduce them in an upcoming revision of the standard. Yet, anonymous functions are a very old and very well-known concept in Mathematics and Computer Science (invented by the mathematician Alonzo Church around 1936, and used by the Lisp programming language since 1958, see e.g. here). So why didn't today's mainstream programming languages (many of which originated 15 to 20 years ago) support lambda functions from the very beginning and only introduced them later? And what triggered the massive adoption of anonymous functions in the last few years? Is there some specific event, new requirement or programming technique that started this phenomenon? IMPORTANT NOTE The focus of this question is the introduction of anonymous functions in modern, main-stream (and therefore, maybe with a few exceptions, non functional) languages. Also, note that anonymous functions (blocks) are present in Smalltalk, which is not a functional language, and that normal named functions have been present even in procedural languages like C and Pascal for a long time. Please do not overgeneralize your answers by speaking about "the adoption of the functional paradigm and its benefits", because this is not the topic of the question.

    Read the article

  • F#: Advantages of converting top-level functions to member methods?

    - by J Cooper
    Earlier I requested some feedback on my first F# project. Before closing the question because the scope was too large, someone was kind enough to look it over and leave some feedback. One of the things they mentioned was pointing out that I had a number of regular functions that could be converted to be methods on my datatypes. Dutifully I went through changing things like let getDecisions hand = let (/=/) card1 card2 = matchValue card1 = matchValue card2 let canSplit() = let isPair() = match hand.Cards with | card1 :: card2 :: [] when card1 /=/ card2 -> true | _ -> false not (hasState Splitting hand) && isPair() let decisions = [Hit; Stand] let split = if canSplit() then [Split] else [] let doubleDown = if hasState Initial hand then [DoubleDown] else [] decisions @ split @ doubleDown to this: type Hand // ...stuff... member hand.GetDecisions = let (/=/) (c1 : Card) (c2 : Card) = c1.MatchValue = c2.MatchValue let canSplit() = let isPair() = match hand.Cards with | card1 :: card2 :: [] when card1 /=/ card2 -> true | _ -> false not (hand.HasState Splitting) && isPair() let decisions = [Hit; Stand] let split = if canSplit() then [Split] else [] let doubleDown = if hand.HasState Initial then [DoubleDown] else [] decisions @ split @ doubleDown Now, I don't doubt I'm an idiot, but other than (I'm guessing) making C# interop easier, what did that gain me? Specifically, I found a couple *dis*advantages, not counting the extra work of conversion (which I won't count, since I could have done it this way in the first place, I suppose, although that would have made using F# Interactive more of a pain). For one thing, I'm now no longer able to work with function "pipelining" easily. I had to go and change some |> chained |> calls to (some |> chained).Calls etc. Also, it seemed to make my type system dumber--whereas with my original version, my program needed no type annotations, after converting largely to member methods, I got a bunch of errors about lookups being indeterminate at that point, and I had to go and add type annotations (an example of this is in the (/=/) above). I hope I haven't come off too dubious, as I appreciate the advice I received, and writing idiomatic code is important to me. I'm just curious why the idiom is the way it is :) Thanks!

    Read the article

  • How can arguments to variadic functions be passed by reference in PHP?

    - by outis
    Assuming it's possible, how would one pass arguments by reference to a variadic function without generating a warning in PHP? We can no longer use the '&' operator in a function call, otherwise I'd accept that (even though it would be error prone, should a coder forget it). What inspired this is are old MySQLi wrapper classes that I unearthed (these days, I'd just use PDO). The only difference between the wrappers and the MySQLi classes is the wrappers throw exceptions rather than returning FALSE. class DBException extends RuntimeException {} ... class MySQLi_throwing extends mysqli { ... function prepare($query) { $stmt = parent::prepare($query); if (!$stmt) { throw new DBException($this->error, $this->errno); } return new MySQLi_stmt_throwing($this, $query, $stmt); } } // I don't remember why I switched from extension to composition, but // it shouldn't matter for this question. class MySQLi_stmt_throwing /* extends MySQLi_stmt */ { protected $_link, $_query, $_delegate; public function __construct($link, $query, $prepared) { //parent::__construct($link, $query); $this->_link = $link; $this->_query = $query; $this->_delegate = $prepared; } function bind_param($name, &$var) { return $this->_delegate->bind_param($name, $var); } function __call($name, $args) { //$rslt = call_user_func_array(array($this, 'parent::' . $name), $args); $rslt = call_user_func_array(array($this->_delegate, $name), $args); if (False === $rslt) { throw new DBException($this->_link->error, $this->errno); } return $rslt; } } The difficulty lies in calling methods such as bind_result on the wrapper. Constant-arity functions (e.g. bind_param) can be explicitly defined, allowing for pass-by-reference. bind_result, however, needs all arguments to be pass-by-reference. If you call bind_result on an instance of MySQLi_stmt_throwing as-is, the arguments are passed by value and the binding won't take. try { $id = Null; $stmt = $db->prepare('SELECT id FROM tbl WHERE ...'); $stmt->execute() $stmt->bind_result($id); // $id is still null at this point ... } catch (DBException $exc) { ... } Since the above classes are no longer in use, this question is merely a matter of curiosity. Alternate approaches to the wrapper classes are not relevant. Defining a method with a bunch of arguments taking Null default values is not correct (what if you define 20 arguments, but the function is called with 21?). Answers don't even need to be written in terms of MySQL_stmt_throwing; it exists simply to provide a concrete example.

    Read the article

  • Is it possible to view the "source" for a ksh function?

    - by stevec
    Our ksh environment defines several functions, which can be listed using then "functions" ksh function. Is it possible to see the definition (ie source code) for these functions? This seems like an obvious question, but I've tried all manner of parameters to the "functions" and "function" functions with no luck. Thanks, Steve

    Read the article

  • T-SQL Tuesday #24 : Dude, where's the rest of my procedure?

    - by AaronBertrand
    This month's T-SQL Tuesday is being hosted by Brad Schulz ( blog ) and the topic is one that should attract a lot of submissions: Procedures and Functions. Last week, I talked about the case against INFORMATION_SCHEMA views - I provided several examples where I feel the INFORMATION_SCHEMA views fall short of the catalog views, and expressed my belief that you are better off programming consistently against the catalog views all the time, instead of only when the INFORMATION_SCHEMA views fail. Having...(read more)

    Read the article

  • Looking for terminology for the relation of a subject and a predicate

    - by kostja
    While writing some predicates for collection filtering I have stumbled over the choice of the right words for the relation of the subject and the predicate (English is a foreign language for me). What I ended up writing was "Subjects matching this predicate..." This seems to be incorrect, since predicates are functions and not regular expressions. But saying "Subjects for which this predicate returns true..." sounds awkward to me as well.. So what would be the correct term?

    Read the article

  • Calling SQL Azure's stored procedure in silverlight

    - by sweetsweet
    I have a silverlight application to call the SQL Azure's stored procedure and show the data. I use the service to call stored procedure, and it is working when it is run at VS 2008. But when I integrate in php page, the data is not shown. I think the service is not running. How can I call SQL Azure stored procedure without using service? I cannot use ADO.Net Entity Domain Model and LINQ to SQL(I don't have permission to access that database in GUI). I cannot connect to SQL Azure, so which method can I use to call SQL Azure stored procedure in silverlight? Please give me the information. {I don't know very much about that silverlight. To take the detailes of my project. I want to call SQL Azure's stored procedure. So, I tried to call that Stored Procedure from ADO.Net Entity Domain Model. The problem is I cannot access that SQL Azure database. It show "Buit_in function suer_sname is not supported in this version of SQL server. Therefore, I connect to that Stored Procedure in code beind and call that function in Service and to use that data in presentation layer, I add service reference in silverlight(I mean the service is at the same project). It is perfectly working when it is running at VS. So,I take out xap file and call that xap file in php. The silverlight is running in that PHP page but the data is not shown. I think the service is not hosted. So, how can I solve my problem? I use xampp to run my php page. }

    Read the article

  • I'm new to C++. Please Help me with the Linked List (What functions to add)?

    - by Igal
    DEAR All; Hi, I'm just beginner to C++; Please help me to understand: What functions should be in the Linked list class ? I think there should be overloaded operators << and ; Please help me to improve the code (style, errors, etc,) Thanks for advance. Igal. Please review the small code for the integer List (enclosed MyNODE.h and ListDriver1.cpp); MyNODE.h // This is my first attempt to write linked list. Igal Spector, June 2010. #include <iostream.h> #include <assert.h> //Forward Declaration of the classes: class ListNode; class TheLinkedlist; // Definition of the node (WITH IMPLEMENTATION !!!, without test drive): class ListNode{ friend class TheLinkedlist; public: // constructor: ListNode(const int& value, ListNode *next= 0); // note: no destructor, as this handled by TheLinkedList class. // accessor: return data in the node. // int Show() const {return theData;} private: int theData; //the Data ListNode* theNext; //points to the next node in the list. }; //Implementations: //constructor: inline ListNode::ListNode(const int &value,ListNode *next) :theData(value),theNext(next){} //end of ListNode class, now for the LL class: class TheLinkedlist { public: //constructors: TheLinkedlist(); virtual ~TheLinkedlist(); // Accessors: void InsertAtFront(const &); void AppendAtBack(const &); // void InOrderInsert(const &); bool IsEmpty()const;//predicate function void Print() const; private: ListNode * Head; //pointer to first node ListNode * Tail; //pointer to last node. }; //Implementation: //Default constructor inline TheLinkedlist::TheLinkedlist():Head(0),Tail(0) {} //Destructor inline TheLinkedlist::~TheLinkedlist(){ if(!IsEmpty()){ //list is not empty cout<<"\n\tDestroying Nodes"<<endl; ListNode *currentPointer=Head, *tempPtr; while(currentPointer != 0){ //Delete remaining Nodes. tempPtr=currentPointer; cout<<"The node: "<<tempPtr->theData <<" is Destroyed."<<endl<<endl; currentPointer=currentPointer->theNext; delete tempPtr; } Head=Tail = 0; //don't forget this, as it may be checked one day. } } //Insert the Node to the beginning of the list: void TheLinkedlist::InsertAtFront(const int& value){ ListNode *newPtr = new ListNode(value,Head); assert(newPtr!=0); if(IsEmpty()) //list is empty Head = Tail = newPtr; else { //list is NOT empty newPtr->theNext = Head; Head = newPtr; } } //Insert the Node to the beginning of the list: void TheLinkedlist::AppendAtBack(const int& value){ ListNode *newPtr = new ListNode(value, NULL); assert(newPtr!=0); if(IsEmpty()) //list is empty Head = Tail = newPtr; else { //list is NOT empty Tail->theNext = newPtr; Tail = newPtr; } } //is the list empty? inline bool TheLinkedlist::IsEmpty() const { return (Head == 0); } // Display the contents of the list void TheLinkedlist::Print()const{ if ( IsEmpty() ){ cout << "\n\t The list is empty!!"<<endl; return; } ListNode *tempPTR = Head; cout<<"\n\t The List is: "; while ( tempPTR != 0 ){ cout<< tempPTR->theData <<" "; tempPTR = tempPTR->theNext; } cout<<endl<<endl; } ////////////////////////////////////// The test Driver: //Driver test for integer Linked List. #include <iostream.h> #include "MyNODE.h" // main Driver int main(){ cout<< "\n\t This is the test for integer LinkedList."<<endl; const int arraySize=11, ARRAY[arraySize]={44,77,88,99,11,2,22,204,50,58,12}; cout << "\n\tThe array is: "; //print the numbers. for (int i=0;i<arraySize; i++) cout<<ARRAY[i]<<", "; TheLinkedlist list; //declare the list for(int index=0;index<arraySize;index++) list.AppendAtBack( ARRAY[index] );//create the list cout<<endl<<endl; list.Print(); //print the list return 0; //end of the program. }

    Read the article

  • List stored functions using a table in PostgreSQL

    - by Paolo B.
    Just a quick and simple question: in PostgreSQL, how do you list the names of all stored functions/stored procedures using a table using just a SELECT statement, if possible? If a simple SELECT is insufficient, I can make do with a stored function. My question, I think, is somewhat similar to this other question, but this other question is for SQL Server 2005: http://stackoverflow.com/questions/119679/list-of-stored-procedure-from-table (optional) For that matter, how do you also list the triggers and constraints that use the same table in the same manner?

    Read the article

  • Port to use CentOS init.d functions

    - by jcalfee314
    What are good equivalent centos commands using functions in /etc/init.d/functions such as daemon to perform the following tasks? STARTCMD='start-stop-daemon --start --exec /usr/sbin/swapspace --quiet --pidfile /var/run/swapspace.pid -- -d -p' STOPCMD='start-stop-daemon --stop --oknodo --quiet --pidfile /var/run/swapspace.pid' It looks like daemon will work for the start command and killproc is used for the stop command. . /etc/init.d/functions pushd /usr/sbin daemon --pidfile /var/run/swapspace.pid /usr/sbin/swapspace . /etc/init.d/functions killproc -p $(cat /var/run/swapspace.pid) Would the --oknodo be needed in the CentOS env (the swap file is really only boot-time)? "oknodo - Return exit status 0 instead of 1 if no actions are (would be) taken." I don't see quiet in daemon or killproc, I can't imagine that it would matter though. The original start-stop-daemon for swapspace seems to have both -p and --pidfile (the same command). That must be an error. Did I miss anything? Any idea why daemon not create the pid file?

    Read the article

  • Where are global variables stored in memory?

    - by Jack
    Are they stored in the heap or there is separate area where they are stored? Similarly where are static variables stored in memory. They can't be stored in frames as they will get destroyed when the function returns. PS - Can someone suggest a good book that talks about memory mapping for C/C++.

    Read the article

  • SQL SERVER – Introduction to PERCENTILE_CONT() – Analytic Functions Introduced in SQL Server 2012

    - by pinaldave
    SQL Server 2012 introduces new analytical function PERCENTILE_CONT(). The book online gives following definition of this function: Computes a specific percentile for sorted values in an entire rowset or within distinct partitions of a rowset in Microsoft SQL Server 2012 Release Candidate 0 (RC 0). For a given percentile value P, PERCENTILE_DISC sorts the values of the expression in the ORDER BY clause and returns the value with the smallest CUME_DIST value (with respect to the same sort specification) that is greater than or equal to P. If you are clear with understanding of the function – no need to read further. If you got lost here is the same in simple words – it is lot like finding median with percentile value. Now let’s have fun following query: USE AdventureWorks GO SELECT SalesOrderID, OrderQty, ProductID, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY ProductID) OVER (PARTITION BY SalesOrderID) AS MedianCont FROM Sales.SalesOrderDetail WHERE SalesOrderID IN (43670, 43669, 43667, 43663) ORDER BY SalesOrderID DESC GO The above query will give us the following result: You can see that I have used PERCENTILE_COUNT(0.5) in query, which is similar to finding median. Let me explain above diagram with little more explanation. The defination of median is as following: In case of Even Number of elements = In ordered list add the two digits from the middle and devide by 2 In case of Odd Numbers of elements = In ordered list select the digits from the middle I hope this example gives clear idea how PERCENTILE_CONT() works. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, PostADay, SQL, SQL Authority, SQL Function, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • Temporary Tables in Stored Procedures

    - by Paul White
    Ask anyone what the primary advantage of temporary tables over table variables is, and the chances are they will say that temporary tables support statistics and table variables do not. This is true, of course; even the indexes that enforce PRIMARY KEY and UNIQUE constraints on table variables do not have populated statistics associated with them, and it is not possible to manually create statistics or non-constraint indexes on table variables. Intuitively, then, any query that has alternative execution...(read more)

    Read the article

  • Gathering all data in single iteration vs using functions for readable code

    - by user828584
    Say I have an array of runners with which I need to find the tallest runner, the fastest runner, and the lightest runner. It seems like the most readable solution would be: runners = getRunners(); tallestRunner = getTallestRunner(runners); fastestRunner = getFastestRunner(runners); lightestRunner = getLightestRunner(runners); ..where each function iterates over the runners and keeps track of the largest height, greatest speed, and lowest weight. Iterating over the array three times, however, doesn't seem like a very good idea. It would instead be better to do: int greatestHeght, greatestSpeed, leastWeight; Runner tallestRunner, fastestRunner, lightestRunner; for(runner in runners){ if(runner.height > greatestHeight) { greatestHeight = runner.height; tallestRunner = runner; } if(runner.speed > ... } While this isn't too unreadable, it can get messy when there is more logic for each piece of information being extracted in the iteration. What's the middle ground here? How can I use only a single iteration while still keeping the code divided into logical units?

    Read the article

  • My PowerShell functions do not appear to be used

    - by Frank
    Hi there, I have a ps1 script in which I define 2 functions as such: function Invoke-Sql([string]$query) { Invoke-Sqlcmd -ServerInstance $Server -Database $DB -User $User -Password $Password -Query $query } function Get-Queued { Invoke-Sql "Select * From Comment where AwaitsModeration = 1" } I then call the ps1 file by typing it in (it's in a folder in the path, and autocompletion works) However, I cannot start using the functions. I am confused, because when I copy / paste the functions into the console, all is fine and they work. I also have a function defined in my profile, and it works. Where am I thinking wrong, why doesn't it work what I'm trying to do?

    Read the article

  • Is it possible to make a MS-SQL Scalar function do this?

    - by Hokken
    I have a 3rd party application that can call a MS-SQL scalar function to return some summary information from a table. I was able to return the summary values with a table-valued function, but the application won't utilize table-valued functions, so I'm kind of stuck. Here's a sample from the table: trackingNumber, projTaskAward, expenditureType, amount 1122, 12345-67-89, Supplies, 100 1122, 12345-67-89, Supplies, 150 1122, 12345-67-89, Supplies, 250 1122, 12345-67-89, Misc, 50 1122, 12345-67-89, Misc, 100 1122, 98765-43-21, General, 200 1122, 98765-43-21, Conference, 500 1122, 98765-43-21, Misc, 300 1122, 98765-43-21, Misc, 100 1122, 98765-43-21, Misc, 100 I want to summarize the amounts by projTaskAward & expenditureType, based on the trackingNumber. Here is the output I'm looking for: Proj/Task/Award: 12345-67-89 Expenditure Type: Supplies Total: 500 Proj/Task/Award: 12345-67-89 Expenditure Type: Misc Total: 150 Proj/Task/Award: 98765-43-21 Expenditure Type: General Total: 200 Proj/Task/Award: 98765-43-21 Expenditure Type: Conference Total: 500 Proj/Task/Award: 98765-43-21 Expenditure Type: Misc Total: 500 I'd appreciate any help anyone can give in steering me in the right direction.

    Read the article

  • Settings for multiple monitors are not stored

    - by JJD
    I am running Ubuntu 12.04. on a Lenovo Thinkpad T400. I connected an external monitor as a second display. The laptop stands under the external screen. The laptop has a native resolution of 1440x900 (16:10), the external monitor 1280x1024 (5:4). There are two graphic adapters: one internal Intel GMA 4500 MHD and an discrete ATI card. Currently, the integrated Intel is enabled. I use the Display application to arrange the position of the monitors so it look like this: The problem: Whenever I restart my computer the configuration gets lost. First, the displays are mirrored instead of extended. I have to press Fn + F7 two times to switch to extended mode. Second, the Display settings still look like this: I know this worked once when I was running Ubuntu 10.10. I cannot tell since when it does not work. Do you know how I can permanently store the settings?

    Read the article

  • Access local email stored on worstation on laptop on lan

    - by crafter
    I have the following scenario with my email : I am using Evolution as my primary email client on my workstation. The evolution mail is downloaded from my mail servers using POP, then deleted from the server. When I am mobile, I access my email on my email server using webmail. My laptop is my primary computer thesedays. The workstation is hardly used. When I am mobile, I am restricted to new email that has not been downloaded onto the workstation I am now looking for a way to access my email from my workstation on my laptop, amlost as if my workstation is my second level email server/ I tried evolution on X display but attachments will browse on my workstation (not ideal as most docs are on my laptop). I am open to changing mail client or installing a service on my workstation. What would be the best way to address this requirement?

    Read the article

  • MySQL Input Parameters Add Flexibility to Crosstab Stored Procedures

    When generating a result set where the query contains an unknown number of column and/or row values we can use a combination of Prepared Statements, which allows us to tailor the output based on the number of data values. We can also add input parameters to a procedure to assign the field names, aliases, and even the aggregate function!

    Read the article

  • MySQL Input Parameters Add Flexibility to Crosstab Stored Procedures

    When generating a result set where the query contains an unknown number of column and/or row values we can use a combination of Prepared Statements, which allows us to tailor the output based on the number of data values. We can also add input parameters to a procedure to assign the field names, aliases, and even the aggregate function!

    Read the article

  • Could not apply stored configuration for monitors

    - by Hernantz
    Well this happened when I upgraded to Natty. Not only seems I can't change my resolution to higher than 1024x768 but it appears at the left and using only 70% of the monitor's width. I tried logging in but in ubuntu classic mode, and i was able to change it, but that trick did not work anymore. (May this be a compiz problem?) Anyways, here is my /var/log/Xorg.0.log http://pastebin.com/Ew4wwLab and lspci -nn | grep VGA: 00:02.0 VGA compatible controller [0300]: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller [8086:27a2] (rev 03) I tried using xrandr for adding manually a resolution of 1280x1768 but without luck. Here is the xrandr output Screen 0: minimum 320 x 200, current 1024 x 768, maximum 4096 x 4096 LVDS1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm 1024x768 60.0*+ 800x600 60.3 56.2 640x480 59.9 VGA1 disconnected (normal left inverted right x axis y axis) TV1 disconnected (normal left inverted right x axis y axis) 1280x1024 (0xc6) 109.0MHz h: width 1280 start 1368 end 1496 total 1712 skew 0 clock 63.7KHz v: height 1024 start 1027 end 1034 total 1063 clock 59.9Hz

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >