Note that there are some explanatory texts on larger screens.

plurals
  1. POErrors in compilation: Can't find any problems with headers, classes, and class interfaces
    primarykey
    data
    text
    <p>I do not understand the error in compilation. I don't see any syntax problems.</p> <p>Errors:</p> <pre><code>/dev/shm/ccEF5pIa.o: In function `main': fig03_13.cc:(.text+0x45): undefined reference to `GradeBook::GradeBook(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)' fig03_13.cc:(.text+0x9d): undefined reference to `GradeBook::GradeBook(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)' fig03_13.cc:(.text+0xce): undefined reference to `GradeBook::getCourseName()' fig03_13.cc:(.text+0xe1): undefined reference to `GradeBook::getCourseName()' collect2: ld returned 1 exit status GradeBook.cc:21:8: error: prototype for 'std::string GradeBook::displayMessage()' does not match any in class 'GradeBook' GradeBook.h:15:8: error: candidate is: void GradeBook::displayMessage() </code></pre> <p>This is GradeBook.h</p> <pre><code>#include &lt;string&gt; // class GradeBook uses C++ standard string class using namespace std; // GradeBook class definition class GradeBook { public: GradeBook(string); // constructor that initializes courseName void setCourseName(string); // function that sets the course name string getCourseName(); // function that gets the course name void displayMessage(); // function that displays a welcome message private: string courseName; // course name for this GradeBook }; </code></pre> <p>GradeBook.cc</p> <pre><code>#include &lt;iostream&gt; #include "GradeBook.h" // include definition of class GradeBook using namespace std; // constructor initializes courseName with string supplied as argument GradeBook::GradeBook(string name) { setCourseName(name); // call set function to initialize courseName } // end GradeBook constructor // function to set the course name void GradeBook::setCourseName(string name) { courseName = name; // store the course name in the object } // end function setCourseName // function to get the course name string GradeBook::displayMessage() { // call getCourseName to get the courseName cout &lt;&lt; "welcome to the grade book for\n" &lt;&lt; getCourseName() &lt;&lt; "!" &lt;&lt; endl; } // end function displayMessage </code></pre> <p>fig03_13.cc</p> <pre><code>#include &lt;iostream&gt; #include "GradeBook.h" // include definition of class GradeBook using namespace std; // function main begins program execution int main() { // create two GradeBook objects GradeBook gradeBook1("CS101 Introduction to C++ Programming"); GradeBook gradeBook2("CS102 Data Structures in C++"); // display initial value of courseName for each GradeBook cout &lt;&lt; "gradeBook1 created for course: " &lt;&lt; gradeBook1.getCourseName() &lt;&lt; "\ngradeBook2 created for course: " &lt;&lt; gradeBook2.getCourseName() &lt;&lt; endl; } // end main </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload