Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't find the error
    primarykey
    data
    text
    <p>This program is a nightmare, it wont even give me errors when ran, visual studios tells me nothing and i need some help</p> <pre><code>#include &lt;iostream&gt; using namespace std; class Textbook { private: char *aPtr; char *tPtr; int yearPub; int numPages; char bookType; public: Textbook(char *, char *, int, int, char); void display(); void operator=(Textbook&amp;); }; Textbook::Textbook(char*string = NULL, char*string2 = NULL, int ypub = 0, int npages = 0, char btype = 'X') { aPtr = new char[strlen(string) +1]; strcpy(aPtr, string); tPtr = new char[strlen(string2) +1]; strcpy(tPtr, string2); yearPub = ypub; numPages = npages; bookType = btype; } void Textbook::display() { cout &lt;&lt; "The name of the author is: " &lt;&lt; *aPtr &lt;&lt; endl; cout &lt;&lt; "The Title of the book is: " &lt;&lt; *tPtr &lt;&lt; endl; cout &lt;&lt; "The year it was published is: " &lt;&lt; yearPub &lt;&lt; endl; cout &lt;&lt; "The number of pages is: " &lt;&lt; numPages &lt;&lt; endl; cout &lt;&lt; "The initial of the title is: " &lt;&lt; bookType &lt;&lt; endl; return; } void Textbook::operator=(Textbook&amp; newbook) { if(aPtr != NULL) //check that it exists delete(aPtr);// delete if neccessary aPtr = new char[strlen(newbook.aPtr) + 1]; strcpy(aPtr, newbook.aPtr); if(tPtr != NULL) //check that it exists delete(tPtr); // delete if neccessary tPtr = new char[strlen(newbook.tPtr) + 1]; strcpy(tPtr, newbook.tPtr); yearPub = newbook.yearPub; numPages = newbook.numPages; bookType = newbook.bookType; } void main() { Textbook book1("sehwag", "Programming Methods", 2009, 200, 'H'); Textbook book2("Ashwin", "Security Implementation", 2011, 437, 'P'); Textbook book3; book1.display(); book2.display(); book3.display(); book3 = book1; book2 = book3; book1.display(); book2.display(); book3.display(); } </code></pre> <p>im not sure if the problem lies in the default constructor but that's about the only thing i could think of, but im not sure at all on how to fix it.</p>
    singulars
    1. This table or related slice is empty.
    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