Write a program in C++ object oriented programming Create a class Class1 with a string data member ‘paragraph’. Provide a constructor and getParagraph() method in the class. The constructor just assigns NULL to the data member. getParagraph() method must read a paragraph from user. The paragraph should contain at least 30 words. If there are less than 20 words, the program must ask user to enter paragraph again. Create another class Class2, and make it a friend of the class Class1. Provide a function getSubString(Class1 &obj1, int startIndex, int lastIndex) with return type string in the class Class2 which accepts an object of class Class1 (by reference) and two integers. The getSubString() function should return the substring starting from location startIndex and ending at location lastIndex. Class2 must also contain a store() function that stores the substring in a file. Print screenshot of substring stored in file as well. (Topics covered: File Handling, Friend Classes.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

Write a program in C++ object oriented programming Create a class Class1 with a string data member ‘paragraph’. Provide a constructor and getParagraph() method in the class. The constructor just assigns NULL to the data member. getParagraph() method must read a paragraph from user. The paragraph should contain at least 30 words. If there are less than 20 words, the program must ask user to enter paragraph again. Create another class Class2, and make it a friend of the class Class1. Provide a function getSubString(Class1 &obj1, int startIndex, int lastIndex) with return type string in the class Class2 which accepts an object of class Class1 (by reference) and two integers. The getSubString() function should return the substring starting from location startIndex and ending at location lastIndex. Class2 must also contain a store() function that stores the substring in a file. Print screenshot of substring stored in file as well. (Topics covered: File Handling, Friend Classes.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT