C++ Introduction to Programming It is short and simple practice. Please solve #1
ID: 3775535 • Letter: C
Question
C++ Introduction to Programming
It is short and simple practice.
Please solve #1,2,3,4,5
#include<iostream>
...
Classes: members and methods
Classes, continued: access specifiers and constructors
Classes for object oriented design
Recursion
Multi-file projects and header files
Exceptions, tests, and assertions
Assertions, Advanced Input/Output
Operator Overloading; Inheritance and Abstract data types
Explanation / Answer
1.
User enters 1 :prints the LE
User enters 2 :prints the Unknown
2.
try
{
}
catch(domain_error& e)
{
}
catch(logic_error& e)
{
}
catch(exception& e )
{
}
exception is the base for all exceptions that is handeled at the last catch block
3.
a) #include"tools.h" and #include"core.h" should be included in the main.cpp file
b) core.cpp file should included #include"core.h"
4.
Function Declaration: .h
Class Definition : .h and .cpp
Method Definition: .cpp
Function Definition: .cpp
//5.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int number_of_lines = 0;
string line;
ifstream myfile("wordfile.txt");
while (myfile.good ())
{
getline(myfile, line);
++number_of_lines;
}
cout << "Number of lines is "<<number_of_lines<< endl;
return 0;
}
wordfile.txt
word1
word2
word3
word4
word5
OUTPUT:
Number of lines is 5
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.