Question: I am having trouble with a simple C++ program: Here is what I have coded thus far: I have error messages that read: In function

I am having trouble with a simple C++ program:

I am having trouble with a simple C++ program: Here is what

Here is what I have coded thus far:

I have coded thus far: I have error messages that read: In

I have error messages that read:

In function int main():

error: invalid initialization of reference of type std::ifstream& {aka std::basic_ifstream&} from expression of type std::ofstream {aka std::basic_ofstream} myLineCounter(textFile);

note: in passing argument 1 of int myLineCounter(std::ifstream&) int myLineCounter(ifstream& myFile); ^~~~~~~~~~~~~

In function int myLineCounter(std::ifstream&):

error: declaration of std::ifstream myFile shadows a parameter ifstream myFile("sample.txt"); ^ Any help would be appreciated.

Create a sample text called sample.txt, with multiple lines and spaces between these ines Open and read the file using file operations. Create a function called myLineCounter and count the number of lines in the file, also print the value that you get. 1. 2. 3. myLineCounter(ifstream& myFile) For example, if my sample text looks like this: The Project Gutenberg EBook of The Adventures of Sherlock Holmes by Sir Arthur Conan The Project Gutenberg EBook of The Adventures of Sherlock Holmes by Slir Arthur Conan Doyle (#15 in our series by Sir Arthur Conan Doyle) Copyright laws are changing all over the world. Be sure to check the copyright laws for your country before downloading or redistributing this or any other Project Gutenberg eBook. Your output should be: This file has 4 lines

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!