1. Why the code showing error? 4 //File1- mystring.h #define -CRT-SECURE-NO-WARN
ID: 3716003 • Letter: 1
Question
1. Why the code showing error?
4 //File1- mystring.h #define -CRT-SECURE-NO-WARNINGS 5 6 #include #include«iostream» 'mystring.h' file not found 8 #include 9 using namespace std; 10 class myString 12 private: 13 14 5 public: string mystr; int SIZE myString); myString(string mystring); myString(const myString&); -myString); void showStructure); unsigned int getLength char operator)(int i); myString& operator=(const mystring&); bool operator (const myString& rhs); bool operator-(const myString& rhs); friend istream &operator;>>(istream& input, myString& rhs); myString toUpper; myString toLower void clear 17 18 19 20 21 23 24 25 26 27 28 29 30 31 32 // File2 -mystring.cpp 33 #include«iostream» 34 #include 35 using namespace std; 36 char myString::operator[](int i) 37 38 39 if (i> SIZE) cout s "Index out of bounds"Explanation / Answer
Solution:
The error is coming because you haven't placed mystring.h header file in the same folder/package where you are executing your program.
I guess mystring.h is a user generated header file.
The second error is because the cout statement is running in myString::
The function pointer is treated as a manipulator. A built-in operator << takes the pointer to the string "Index out of bounds" and calls it with cout. but that reference is not available.
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.