
607 N.W.2d 227 (2000)
9 Neb. App. 40
NEBRASKA BEEF, LTD., appellant,
v.
UNIVERSAL SURETY COMPANY, appellee.
No. A-98-1373.
Court of Appeals of Nebraska.
March 14, 2000.
*231 David S. Houghton and J.P. Sam King, of Lieben, Whitted, Houghton, Slowiaczek and Cavanaugh, P.C., Omaha, for appellant.
David A. Hecker, of Woods & Aitken, Lincoln, for appellee.
IRWIN, Chief Judge, and CARLSON, Judge, and HOWARD, District Judge, Retired.
CARLSON, Judge.

INTRODUCTION
Nebraska Beef, Ltd., appeals from the trial court's sustaining of a demurrer upon its breach of contract and negligence claims against Universal Surety Company, and the subsequent dismissal of its petition. For the reasons set forth below, we affirm in part, and in part reverse and remand with direction.

BACKGROUND
According to the petition filed by Nebraska Beef, on or about April 28, 1995, Nebraska Beef entered into an oral agreement with a general contractor, J.B. Contracting Services, Inc. (JBC), pursuant to which JBC would provide construction management and general contractor services relating to the construction of an addition to the Omaha meatpacking facilities of Nebraska Beef. Also on or about April 28, JBC entered into a subcontract with ABC Electric, Inc. (ABC), for certain electrical work associated with the Nebraska Beef project. At ABC's request, on or about May 16, Universal Surety executed and delivered a performance bond naming ABC as principal and JBC as the sole obligee, in the amount of $880,000. The bond further provided that "[n]o right of action shall accrue on this bond to or for the use of any person or corporation other than the Obligee named herein or the heirs, executors, administrators or successors of the Obligee." On May 22, a dual obligee rider was executed, naming Norwest of Nebraska N.A. as an additional obligee. That rider provided, inter alia, that "ABC Electric, Inc., as Contractor entered into a written agreement with J B Contracting Services, Inc. as Owner...."
Nebraska Beef alleged that ABC defaulted on its contractual obligations. Nebraska Beef asserted two causes of action against JBC, alleging breach of contract and negligence. With regard to the breach of contract claim, Nebraska Beef alleged that Universal Surety intended its "duties and obligations under the Performance Bond ... to be performed for the benefit of Nebraska Beef. It further alleged that JBC performed all its contractual obligations, but that ABC had failed to perform certain labor and failed to furnish certain materials required for the installation and completion of the required electrical work. The petition further alleged that ABC and Universal Surety, after notice, failed to remedy the defaults of ABC, that "arrangements were made for the performance of ABC's obligations under the Subcontract," and that Nebraska Beef was entitled to recover $880,000.
With regard to the negligence claim, Nebraska Beef, having incorporated the previous allegations, further alleged that Universal Surety negligently arranged for performance of ABC's contractual obligations, resulting in unspecified damages to Nebraska Beef. The petition also alleged that ABC and Universal Surety were *232 informed of the deficiencies of ABC's performance.
Universal Surety demurred to both causes of action on January 28, 1998, asserting that each count failed to state a valid cause of action. On May 27, the district court sustained the demurrer by Universal Surety. With regard to the breach of contract claim, the court found that Nebraska Beef was neither a party to the bond nor a third-party beneficiary of the bond and, accordingly, not a proper party to bring a cause of action based upon breach of that bond. With regard to the negligence cause of action, the court found that this was an action based upon contract and that the "statements regarding the negligence cause of action must be considered surplusage." The district court further found that no possibility existed for an amendment that would correct the defects in the petition and, accordingly, denied leave to amend.
Nebraska Beef moved for a new trial. That motion was heard on August 14, 1998, and the motion was denied on November 24. The instant notice of appeal was filed on December 23.

ASSIGNMENTS OF ERROR
Nebraska Beef asserts that the district court erred in sustaining the demurrer by Universal Surety and in subsequently dismissing its petition. Nebraska Beef also asserts that the district court erred in overruling its motion for new trial.

STANDARD OF REVIEW
On appeal, an order sustaining a demurrer will be affirmed if any one of the grounds on which it was asserted is well taken. Fox v. Metromail of Delaware, 249 Neb. 610, 544 N.W.2d 833 (1996).
When a demurrer to a petition is sustained, a court must grant leave to amend the petition unless it is clear that no reasonable possibility exists that amendment will correct the defect. Giese v. Stice, 252 Neb. 913, 567 N.W.2d 156 (1997). Before error can be predicated upon the refusal of a trial court to permit an amendment to a petition after a demurrer is sustained, the record must show that, under the circumstances, the ruling of the court was an abuse of discretion. Thrift Mart v. State Farm Fire & Cas. Co., 251 Neb. 448, 558 N.W.2d 531 (1997), overruled on other grounds, Hornig v. Martel Lift Systems, 258 Neb. 764, 606 N.W.2d 764 (2000).
Whether a petition states a cause of action is a question of law regarding which an appellate court has an obligation to reach a conclusion independent of that of the inferior court. Cobb v. Sure Crop Chem. Co., 255 Neb. 625, 587 N.W.2d 355 (1998). If a petition, liberally construed, states a cause of action, a demurrer based on the failure to state a cause of action will be overruled. Id.
A motion for new trial is addressed to the discretion of the trial court, whose decision will be upheld in the absence of an abuse of that discretion. Barnett v. Peters, 254 Neb. 74, 574 N.W.2d 487 (1998).

ANALYSIS

Demurrers.
When reviewing an order sustaining a demurrer, an appellate court accepts the truth of the facts which are well pled, together with the proper and reasonable inferences of law and fact which may be drawn therefrom, but does not accept as true the conclusions of the pleader. Giese, supra; PSB Credit Servs. v. Rich, 251 Neb. 474, 558 N.W.2d 295 (1997).
In considering a demurrer, a court must assume that the facts pled, as distinguished from legal conclusions, are true as alleged and must give the pleading the benefit of any reasonable inference from the facts alleged, but cannot assume the existence of facts not alleged, make factual findings to aid the pleading, or consider evidence which might be adduced at trial. *233 Giese, supra; Baltensperger v. Wellensiek, 250 Neb. 938, 554 N.W.2d 137 (1996).
In determining whether a cause of action has been stated, a petition is to be construed liberally. If as so construed the petition states a cause of action, a demurrer based on the failure to state a cause of action must be overruled. State ex rel. Keener v. Graff, 251 Neb. 571, 558 N.W.2d 538 (1997); Crider v. Bayard City Schools, 250 Neb. 775, 553 N.W.2d 147 (1996). A demurrer reaches an exhibit filed with the petition and made a part thereof, so that a court can consider such exhibit in determining whether the petition states a cause of action. Leader Nat. Ins. v. American Hardware Ins., 249 Neb. 783, 545 N.W.2d 451 (1996). This includes an attached surety bond. See Cagle, Inc. v. Sammons, 198 Neb. 595, 254 N.W.2d 398 (1977).

Contractual Cause of Action.
The surety bond at issue here listed ABC as principal, Universal Surety as surety, and JBC as obligee. It expressly excluded all other parties, stating that "[n]o right of action shall accrue on this bond to or for the use of any person or corporation other than the Obligee named herein or the heirs, executors, administrators or successors of the Obligee." The law, in Nebraska and elsewhere, has long been as follows:
"A surety cannot be held beyond the precise terms of his contract. Any intention on the part of the surety to assume a further and continued liability must be found in the words of the contract made. It is not a matter of inference, but of express statement. The liability of a surety, therefore, is measured by, and will not be extended beyond, the strict terms of his contract."
Farmers Union Co-op Assn. v. Mid-States Constr. Co., 212 Neb. 147, 153, 322 N.W.2d 373, 377 (1982) (quoting Rawleigh Co. v. Smith, 142 Neb. 527, 9 N.W.2d 286 (1943)). See Young v. General Insurance Co. of America, 33 Ill.App.3d 119, 121, 337 N.E.2d 739, 741 (1975) ("[i]n order for a third person to recover on a performance bond which on its face is for the use of other parties, the primary object and purpose of the bond must be for the benefit of the third party and it must have been made for the direct benefit of the third party"). See, generally, Restatement of Security § 165, comment c. at 459 (1941) ("[t]he surety is not liable to laborers and materialmen, even if he guarantees to ... a private owner that the contractor will pay for labor and materials, if the surety in terms provides in his contract that his liability is only to the creditor with whom he contracts. The surety in general is bound only on the contract he makes, and if he excludes any purpose to benefit those outside the contract, there will be no third party beneficiaries, assuming that the surety's provision is valid." (Emphasis supplied)).
Nebraska Beef nonetheless asserts that it is entitled to bring a breach of contract claim because it has sufficiently alleged that it was an intended third-party beneficiary of the performance bond. We disagree.
In order for those not named as parties to a contract to recover thereunder as third-party beneficiaries, it must appear by express stipulation or by reasonable intendment that the rights and interests of such unnamed parties were contemplated and provision was made for them. Marten v. Staab, 249 Neb. 299, 543 N.W.2d 436 (1996); Properties Inv. Group v. Applied Communications, 242 Neb. 464, 495 N.W.2d 483 (1993); Alder v. First Nat. Bank & Trust Co., 241 Neb. 873, 491 N.W.2d 686 (1992). Nebraska Beef first argues that several references to the phrase "owner" within the subcontract between ABC and JBC constitute a "reasonable intendment" that the bond was intended for the benefit of Nebraska Beef, in its role as "owner" of the project. However, none of the clauses within the subcontract relate to Universal Surety's obligations *234 under the bond. Moreover, the dual obligation rider expressly refers to JBC as owner of the performance bond. This argument is accordingly without merit.
Nebraska Beef next argues that its allegation that JBC and Nebraska Beef took actions together to enforce the terms of the performance bond demonstrates that Universal Surety intended to perform its duties and obligations under the performance bond for the benefit of Nebraska Beef. We disagree. The mere allegation of cooperative action by these parties hardly rises to the level of "express stipulation," and, without more, does not support a finding that the parties intended Nebraska Beef to be a third-party beneficiary. Similarly, we find nothing in these pleadings supporting Nebraska Beef's arguments that it could be deemed a third-party beneficiary on the grounds of novation or assignment.
In sum, Nebraska Beef has failed to allege facts sufficient to support an inference that it was meant to be a third-party beneficiary of the surety bond. Accordingly, the district court properly sustained Universal Surety's demurrer to Nebraska Beef's cause of action premised upon a breach of contract theory.

Negligence Cause of Action.
Nebraska Beef next argues that the district court erred in sustaining Universal Surety's demurrer to its negligence cause of action. Generally, one may sue in tort where there has been negligence in performance of a contract. Thomas v. Countryside of Hastings, 246 Neb. 907, 524 N.W.2d 311 (1994). However, for actionable negligence to exist, there must be a legal duty on the part of the defendant to protect the plaintiff from injury, a failure to discharge that duty, and damage proximately resulting from the undischarged duty. Lindsay Mfg. Co. v. Universal Surety Co., 246 Neb. 495, 519 N.W.2d 530 (1994). The question of whether a legal duty exists for actionable negligence is a question of law dependent on the facts in a particular situation. Doe v. Gunny's Ltd. Partnership, 256 Neb. 653, 593 N.W.2d 284 (1999).
The duty of Universal Surety toward Nebraska Beef, if any, is defined by the contractual relationship between the two entities.
Although an aggrieved party may choose a tort action rather than a contract action to remedy alleged negligence in the performance of a contract, nevertheless, the contract may control the scope of a duty undertaken by the defendant.... While Nebraska law allows a party to base a claim for nonperformance of a contractual duty on either a contract or tort theory, in both cases the contract may determine the duty which has been breached with resultant liability.
Getzschman v. Miller Chemical Co., 232 Neb. 885, 899, 443 N.W.2d 260, 270 (1989). In this case, as explained above, there was no contractual relationship between Universal Surety and Nebraska Beef. Accordingly, there can be no cause of action for negligence in the performance of that contract. The district court properly sustained Universal Surety's demurrer to this cause of action.
In sum, because Nebraska Beef is not a direct beneficiary under the surety and cannot claim to be a third-party beneficiary for purposes of its breach of contract claim, it has failed to state a cause of action for breach of contract. Because Nebraska Beef's purported negligence cause of action rests upon a duty discerned from its breach of contract claim, it necessarily cannot bring a cause of action premised upon negligence.

Right to Amend.
However, our holding that the demurrer was properly sustained does not necessarily end our inquiry. When a demurrer to a petition is sustained, the court must allow the plaintiff to amend the petition unless there is no reasonable possibility that an amendment will correct the *235 defect. Association of Commonwealth Claimants v. Moylan, 246 Neb. 88, 517 N.W.2d 94 (1994). Neb.Rev.Stat. § 25-854 (Reissue 1995) provides that if a demurrer is sustained, "the adverse party may amend, if the defect can be remedied by way of amendment." This statute, however, does not provide an absolute right of amendment, nor is it without limitation. Schieffer v. Catholic Archdiocese of Omaha, 244 Neb. 715, 724, 508 N.W.2d 907, 914 (1993) (amendment not permitted where record "does not support a reasonable possibility that the plaintiff could allege additional facts so that the petition would state a cause of action").
Nebraska Beef asserts that it could, if permitted, plead facts in an amended petition that would state one or more valid causes of action. Specifically, Nebraska Beef suggests that it should be permitted to amend to allege a cause of action based on the doctrine of subrogation, citing Cagle, Inc. v. Sammons, 198 Neb. 595, 254 N.W.2d 398 (1977). We agree. In Cagle, Inc., a general contractor had sued a subcontractor and its surety on a breach of contract theory. The surety demurred, and the trial court sustained the demurrer, on the ground that the general contractor "`does not qualify as a "claimant" under the bond as set forth in the petition....'" Id. at 598, 254 N.W.2d at 401. The Supreme Court held that the trial court properly sustained the demurrer, reiterating "[t]he general rule ... that the `surety is bound in the manner and to the extent provided in the obligation.'" Id. at 600, 254 N.W.2d at 402. The Supreme Court then concluded that the general contractor had accordingly failed to state a cause of action.
However, the Supreme Court held that it was error to deny the general contractor an opportunity to amend its petition to state a cause of action under the doctrine of subrogation. The Supreme Court first noted that the appellant had alleged in its petition that the surety had refused to reimburse it for costs it had or was obligated to pay. The court observed that while "this allegation is not specific, it could very well include payment to persons who provided Sammons materials or labor before Sammons withdrew from the job." 198 Neb. at 601-02, 254 N.W.2d at 403. (Emphasis supplied.) The court went on to hold:
[I]t may well be possible for Cagle to state a cause of action on the bond under the doctrine of subrogation if it limits its claim to the value of payments it made to persons who supplied labor or materials to Sammons under a direct contract before Sammons withdrew from the job. Although Cagle's petition ... did not state such a cause of action ... it should be given an opportunity to amend its petition and plead subrogation and the facts out of which the alleged right of subrogation arises. We note that [the surety] complains that Cagle tendered no proposed amendment in connection with its request to amend; however, in light of the trial court's finding that no amendment could state a cause of action, we agree with Cagle that the tendering of an amendment would have been a futile and useless gesture.
Id. at 603-04, 254 N.W.2d at 404.
We believe that Cagle. Inc. compels a similar result in this case. Ordinarily, one seeking subrogation must plead it and set forth the facts from which the right of subrogation arises. Cagle, Inc., supra. Subrogation is the substitution of one person who is not a volunteer, a subrogee, for another, a subrogor, as the result of the subrogee's payment of a debt owed to the subrogor so that the subrogee succeeds to the subrogor's right to recover the amount paid by the subrogee. Shelter Ins. Cos. v. Frohlich, 243 Neb. Ill, 498 N.W.2d 74 (1993). Generally, subrogation is the right of one, who has paid an obligation which another should have paid, to be indemnified by the other. Id.
*236 Absent an agreement, the doctrine of subrogation applies only when a party pays the debts of a third person, not as a volunteer, but either out of a legal or moral obligation to do so or to protect his or her own rights or interests or to save his or her own property. Horton v. Ford Life Ins. Co., 246 Neb. 171, 518 N.W.2d 88 (1994); Rawson v. City of Omaha, 212 Neb. 159, 322 N.W.2d 381 (1982); Cagle, Inc., supra. The doctrine of subrogation is not administered by courts of equity as a legal right, but the principle is applied to subserve the ends of justice and to do equity in the particular case under consideration. Rawson, supra. It does not rest on contract, and no general rule can be laid down which will afford a test for its application in all cases. The facts and circumstances of each case determine whether the doctrine is applicable. Id. It should be noted that as in Cagle, Inc. v. Sammons, 198 Neb. 595, 254 N.W.2d 398 (1977), Nebraska Beef has alleged that other subcontractors were retained to perform ABC's obligations, resulting in payment being made to those other subcontractors.
To state its right of subrogation, Nebraska Beef must plead facts sufficient to show the following material elements: (1) It was compelled to hire subcontractors to replace ABC, out of a legal or moral obligation to do so or to protect its own rights or interests; (2) the cost of those subcontractors should have been paid by Universal Surety pursuant to the performance bond issued by Universal Surety to ABC; (3) Universal Surety failed to pay that cost; and (4) Nebraska Beef paid the debt otherwise owed by Universal Surety to those subcontractors. Compare Horton, supra.
Nebraska Beef further asserts that it could, in an amended petition, allege facts sufficient to establish those elements and that it is entitled to an opportunity to do so. We believe that under the standard in Cagle, Inc., it is entitled to try. "It `generally constitutes an abuse of discretion to sustain a demurrer without leave to amend where there is a reasonable possibility that the defect can be cured by amendment, particularly in the case of an original complaint.'" Cagle, Inc., 198 Neb. at 604, 254 N.W.2d at 404. We accordingly conclude that the trial court abused its discretion in denying Nebraska Beef an opportunity to amend its petition, and we remand this matter to the trial court with direction to give Nebraska Beef leave to file an amended petition alleging a cause of action based upon the doctrine of subrogation. It may also be the case that Nebraska Beef can plead additional facts, absent from the initial petition, that would allow it to bring a breach of contract action based on the theory that it was an intended third-party beneficiary.
Our holding that Nebraska Beef is entitled to file an amended petition obviously makes it unnecessary to address Nebraska Beef's final assignment of error regarding its right to a new trial.

CONCLUSION
For the reasons set forth above, the decision by the district court is affirmed in part and in part reversed and remanded with direction.
AFFIRMED IN PART, AND IN PART REVERSED AND REMANDED WITH DIRECTION.
