Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(main.cpp) #include #include #include #include #include linkedList.h using namespace std; void getAllPuppiesFromFile (string filename, linkedList& allPuppies ) { istringstream inSS; ifstream input(filename); if (input.is_open()) {
(main.cpp)
#include
#include
#include
#include
#include "linkedList.h"
using namespace std;
void getAllPuppiesFromFile (string filename, linkedList& allPuppies )
{
istringstream inSS;
ifstream input(filename);
if (input.is_open()) {
Puppy newPuppy;
while (input >> newPuppy.name >> newPuppy.breed >> newPuppy.age ) {
allPuppies.insertLast(newPuppy);
}
}
else {
cout
}
}
int main ( int argc, char **argv )
{
linkedList allPuppies;
string filename = "puppies.txt";
getAllPuppiesFromFile ( filename, allPuppies );
if ( argc >= 2 ) {
allPuppies.printAll();
}
else {
allPuppies.printOldestPuppy();
}
return 0;
}
(linkedList.cpp)
#include
#include
#include
#include
#include "linkedList.h"
using namespace std;
void getAllPuppiesFromFile (string filename, linkedList& allPuppies )
{
istringstream inSS;
ifstream input(filename);
if (input.is_open()) {
Puppy newPuppy;
while (input >> newPuppy.name >> newPuppy.breed >> newPuppy.age ) {
allPuppies.insertLast(newPuppy);
}
}
else {
cout
}
}
int main ( int argc, char **argv )
{
linkedList allPuppies;
string filename = "puppies.txt";
getAllPuppiesFromFile ( filename, allPuppies );
if ( argc >= 2 ) {
allPuppies.printAll();
}
else {
allPuppies.printOldestPuppy();
}
return 0;
}
(puppies.txt)
Jacky Poodle 12
Bella Beagle 2
Luna Boxer 5
Max Bulldog 6
Shawny Labrador 16
Bailey Terrier 11
Cooper Rottweiler 4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started