Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

Here is what I have coded thus far:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago