{"id":17673,"date":"2022-10-26T13:44:30","date_gmt":"2022-10-26T08:14:30","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/"},"modified":"2022-10-26T13:44:30","modified_gmt":"2022-10-26T08:14:30","slug":"solved-inputing-strings-in-c-using-class-is-not-working-properly","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/","title":{"rendered":"[Solved] Inputing strings in c++ using class is not working properly"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-35711040\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"35711040\" data-parentid=\"35704867\" data-score=\"1\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<ul>\n<li>\n<p>As Bo Persson said, your program does not provide any memory for name and designation. You declare <em>pointers<\/em> like <code>name<\/code> in your class alright, but they do not point to anything. You could just declare e.g. name as <code>char name[100];<\/code> and hope that 100 is enough (and, in production code, add checks to ensure it isn&#8217;t exceeded).<\/p>\n<p>But in C++ there is the string class which frees you of many worries. In particular, it makes input of arbitrarily long strings easy. If the string can&#8217;t have whitespace in it, a simple <code>string s; cin &gt;&gt; s;<\/code> reads a &#8220;word&#8221; from the input into the string. If it <em>can<\/em> have whitespace, you need some way to tell where it starts and ends. Databases, Excel etc. often use quotes to surround a string. If it cannot contain newlines, ensuring that it is on a line of its own is sufficient and obviates the need for parsing. That&#8217;s what we&#8217;ll do here.<\/p>\n<\/li>\n<li>\n<p>The second issue you faced is what&#8217;s technically called &#8220;serialization&#8221;. You want to store (&#8220;persist&#8221;) your class on disk and later (much later, perhaps) re-read it into a new instance. Nathan Oliver pointed you to a resource which discusses serialization. For a simple class like <code>employee<\/code> with a limited number of simple data members we can simply roll our own ad-hoc serialization: We write everything to disk with <code>operator&lt;&lt;()<\/code>, and read everything back with <code>operator&gt;&gt;()<\/code>.<\/p>\n<\/li>\n<li>\n<p>The main thing to consider is that strings may have whitespace, so that we&#8217;ll put them on a line of their own.<\/p>\n<\/li>\n<li>\n<p>An addition is that in order to be more robust when reading from a file we start each employee with a start marker (<code>header<\/code> in the code below). This way reading an employee will work from any position in the file. Also, if later employees should have more fields we can still read our basic employee data and just skip the additional fields before we read the next employee in a sequence of employees on disk.<\/p>\n<\/li>\n<li>\n<p>streams are closed automatically when they are destroyed at the end of their scope; we use block scope for that (check the additional <code>{}<\/code> in the code).<\/p>\n<\/li>\n<li>\n<p>A plain <code>float<\/code> is not precise enough for higher salaries (it only has about 7 decimal digits, so that for salaries &gt; 167772.16 (if I can believe Wikipedia) in whatever currency the pennies start to fall off the cliff). I use <code>long double<\/code> and make sure to not lose precision when converting it to text.<\/p>\n<\/li>\n<li>\n<p>You didn&#8217;t compare reals but I did in order to check whether I read the employee back correctly. Care must be taken there. I wiggle out of the gory details by comparing half pennies which should be appropriate for money.<\/p>\n<\/li>\n<\/ul>\n<p>Here is the whole program. (Compared with my previous version I have simplified the (de)serialization, in particular I have eliminated the useless tags.)<\/p>\n<p>It would be wise to perform error checking after each read\/write in order to make sure it succeeded; remember, a stream coverts to bool, so a simple <code>if(!os) { cerr &lt;&lt; \"oops\" &lt;&lt; endl; \/* exit? *\/}<\/code> is enough; but I didn&#8217;t want to  distract from the actual program too much.<\/p>\n<pre><code>#include &lt;iostream&gt;\n#include &lt;string&gt;\n#include &lt;sstream&gt;\n#include &lt;fstream&gt;\n#include &lt;cfloat&gt;   \/\/ for LDBL_DIG in ostream precision.\n#include &lt;cstdlib&gt;  \/\/ for exit()\nusing namespace std;\n\n\n\/** A simple class holding employee information *\/\nclass employee\n{   \n    public:\n \n        \/** This header starts each \n            \"serialization\" of an employee on a line\n            of its own. *\/\n        static constexpr const char *header = \"--- Employee ---\";\n        \n        \/\/ use C++ std::string\n        string name;\n\n        int age;\n\n        \/\/ use C++ std::string\n        string designation;\n\n        \/\/ Be as precise as possible,\n        \/\/ for later uses like salary increases\n        \/\/ by 4.5% or so :-)\n        \/\/ The salary is in units like USD or EUR.\n        \/\/ The fraction part is pennies, and fractions of them.\n        long double salary;\n\n    public:\n        void readdata(istream &amp;is);\n        void writedata(ostream &amp;os);\n        void display();\n\n        bool operator==(employee &amp;rhs)\n        {   return \n                name == rhs.name \n            &amp;&amp;  age == rhs.age \n            &amp;&amp;  designation == rhs.designation \n            \n            \/\/ Do not compare floats directly.\n            \/\/ We compare pannies, leaving slack for rounding.\n            \/\/ If two salaries round to the same penny value,  \n            \/\/ i.e. 0.01, they are equal for us.\n            \/\/ (This may not be correct, for an accounting app,\n            \/\/ but will do here.)\n            &amp;&amp;  salary - rhs.salary &lt; 0.005 \n            &amp;&amp;  rhs.salary - salary &lt; 0.005;\n        }\n};\n\n\/** Write a header and then \n    each data member in declaration order, converted to text,\n    to the given stream. The header is used to find the start\n    of the next employee; that way we can have comments or other\n    information in the file between employees.\n    The conversion is left to operator&lt;&lt;.\n    Each member is written to a line of its own, so that we\n    can store whitespace in them if applicable.\n    The result is intended to be readable by @readdata().\n*\/\nvoid employee::writedata(ostream &amp;os)\n{           \n    os.precision(LDBL_DIG); \/\/ do not round the long double when printing\n    \n    \/\/ make sure to start on a new line....\n    os                  &lt;&lt; endl\n        \/\/ ... write the header on a single line ...\n        &lt;&lt; header       &lt;&lt; endl\n        \/\/ ... and then the data members.\n        &lt;&lt; name         &lt;&lt; endl\n        &lt;&lt; age          &lt;&lt; endl\n        &lt;&lt; designation  &lt;&lt; endl\n        &lt;&lt; salary       &lt;&lt; endl;\n}\n\n\/** \n    Read an amployee back which was written with @writedata().\n    We first skip lines until we hit a header line,\n    because that's how an employee record starts.\n    Then we read normal data mambers with operator&gt;&gt;. \n    (Strictly spoken, they do not have to be on lines\n    of thier own.)\n    Strings are always on a line of their own,\n    so we remove a newline first.\n*\/\nvoid employee::readdata(istream &amp;is)\n{\n    string buf;\n\n    \n    while(getline(is, buf)) \/\/ stream converts to bool; true is \"ok\"\n    {\n        if( buf == header) break; \/\/ wait for start of employee\n    }\n    if( buf != header ) \n    { \n        cerr &lt;&lt; \"Error: Didn't find employee\" &lt;&lt; endl;\n        return;\n    }\n    \n    getline(is, name);  \/\/ eats newline, too\n    is &gt;&gt; age;          \/\/ does not eat newline:\n    \n    \/\/ therefore skip all up to and including the next newline\n    is.ignore(1000, '\\n');\n    \n    \/\/ line on its own, skips newline\n    getline(is, designation);\n    \n    is &gt;&gt; salary;\n}\n\nint main()\n{\n    const char *const fname = \"emp.txt\";\n    \n    employee empa;\n    empa.name = \"Peter A. Schneider\";\n    empa.age = 42;\n    empa.designation = \"Bicycle Repair Man\";\n    empa.salary = 12345.67;\n\n    employee empb;\n    empb.name = \"Peter B. Schneider\";\n    empb.age = 43;\n    empb.designation = \"Bicycle Repair Woman\";\n    empb.salary = 123456.78;\n\n    {\n        ofstream os(fname);\n        if(!os) \n        { \n            cerr &lt;&lt; \"Couldn't open \" \n            &lt;&lt; fname &lt;&lt; \" for writing, aborting\" &lt;&lt; endl;\n            exit(1);\n        }\n\n        empa.writedata(os);\n        cout &lt;&lt; \"Employee dump:\" &lt;&lt; endl;\n        empa.writedata(cout);\n\n        \/\/ insert a few funny non-employee lines\n        os &lt;&lt; endl &lt;&lt; \"djasdlk\u00f6jsdj\" &lt;&lt; endl &lt;&lt; endl;\n        \n        empb.writedata(os);\n        cout &lt;&lt; \"Employee dump:\" &lt;&lt; endl;\n        empb.writedata(cout);\n    }\n\n    \/\/ show the file contents\n    {\n        ifstream is(fname);\n        if(!is) \n        { \n            cerr &lt;&lt; \"Couldn't open \" \n                &lt;&lt; fname &lt;&lt; \" for reading, aborting\" &lt;&lt; endl;\n            exit(1);\n        }\n\n        string line;\n        cout &lt;&lt; \"-------------- File: -------------\" &lt;&lt; endl;\n        while(getline(is, line)) cout &lt;&lt; line &lt;&lt; endl;\n        cout &lt;&lt; \"---------------End file ----------\" &lt;&lt; endl;\n    }\n    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n    {\n        ifstream is(fname); \/\/ read from the file \"emp.txt\" just written\n        if(!is) \n        { \n            cerr &lt;&lt; \"Couldn't open \" \n                &lt;&lt; fname &lt;&lt; \" for reading, aborting\" &lt;&lt; endl;\n            exit(1);\n        }\n\n        \n        {\n            employee emp2;  \/\/ new employee, sure to be empty\n            cout &lt;&lt; endl &lt;&lt; \"Re-reading an employee...\" &lt;&lt; endl;\n            emp2.readdata(is);\n\n            cout &lt;&lt; endl &lt;&lt; \"Re-read employee dump:\" &lt;&lt; endl;\n            emp2.writedata(cout);\n\n            cout &lt;&lt; \"Original and written\/read employee are \" \n                &lt;&lt; (empa == emp2 ? \"\" : \"NOT \") &lt;&lt; \"equal\" &lt;&lt; endl;\n        }\n    \n        {   \n            employee emp2;  \/\/ new employee, sure to be empty\n            \n            \/\/ now read next employee from same stream.\n            \/\/ readdata() should skip garbage until the header is found.\n            cout &lt;&lt; endl &lt;&lt; \"Re-reading an employee...\" &lt;&lt; endl;\n            emp2.readdata(is);\n\n            cout &lt;&lt; endl &lt;&lt; \"Re-read employee dump:\" &lt;&lt; endl;\n            emp2.writedata(cout);\n\n            cout &lt;&lt; \"Original and written\/read employee are \" \n                &lt;&lt; (empb == emp2 ? \"\" : \"NOT \") &lt;&lt; \"equal\" &lt;&lt; endl;\n        }\n    }\n}\n<\/code><\/pre>\n<p>Sample session:<\/p>\n<pre><code>Employee dump:\n\n--- Employee ---\nPeter A. Schneider\n42\nBicycle Repair Man\n12345.6700000000001\nEmployee dump:\n\n--- Employee ---\nPeter B. Schneider\n43\nBicycle Repair Woman\n123456.779999999999\n-------------- File: -------------\n\n--- Employee ---\nPeter A. Schneider\n42\nBicycle Repair Man\n12345.6700000000001\n\ndjasdlk\u00f6jsdj\n\n\n--- Employee ---\nPeter B. Schneider\n43\nBicycle Repair Woman\n123456.779999999999\n---------------End file ----------\n\nRe-reading an employee...\n\nRe-read employee dump:\n\n--- Employee ---\nPeter A. Schneider\n42\nBicycle Repair Man\n12345.6700000000001\nOriginal and written\/read employee are equal\n\nRe-reading an employee...\n\nRe-read employee dump:\n\n--- Employee ---\nPeter B. Schneider\n43\nBicycle Repair Woman\n123456.779999999999\nOriginal and written\/read employee are equal\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\"><\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved Inputing strings in c++ using class is not working properly <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] As Bo Persson said, your program does not provide any memory for name and designation. You declare pointers like name in your class alright, but they do not point to anything. You could just declare e.g. name as char name[100]; and hope that 100 is enough (and, in production code, add checks to ensure &#8230; <a title=\"[Solved] Inputing strings in c++ using class is not working properly\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/\" aria-label=\"More on [Solved] Inputing strings in c++ using class is not working properly\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[324],"class_list":["post-17673","post","type-post","status-publish","format-standard","hentry","category-solved","tag-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] Inputing strings in c++ using class is not working properly - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] Inputing strings in c++ using class is not working properly - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] As Bo Persson said, your program does not provide any memory for name and designation. You declare pointers like name in your class alright, but they do not point to anything. You could just declare e.g. name as char name[100]; and hope that 100 is enough (and, in production code, add checks to ensure ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-26T08:14:30+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] Inputing strings in c++ using class is not working properly\",\"datePublished\":\"2022-10-26T08:14:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/\"},\"wordCount\":536,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"c++\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/\",\"name\":\"[Solved] Inputing strings in c++ using class is not working properly - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-10-26T08:14:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] Inputing strings in c++ using class is not working properly\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] Inputing strings in c++ using class is not working properly - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] Inputing strings in c++ using class is not working properly - JassWeb","og_description":"[ad_1] As Bo Persson said, your program does not provide any memory for name and designation. You declare pointers like name in your class alright, but they do not point to anything. You could just declare e.g. name as char name[100]; and hope that 100 is enough (and, in production code, add checks to ensure ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/","og_site_name":"JassWeb","article_published_time":"2022-10-26T08:14:30+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] Inputing strings in c++ using class is not working properly","datePublished":"2022-10-26T08:14:30+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/"},"wordCount":536,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["c++"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/","url":"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/","name":"[Solved] Inputing strings in c++ using class is not working properly - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-10-26T08:14:30+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-inputing-strings-in-c-using-class-is-not-working-properly\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] Inputing strings in c++ using class is not working properly"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/17673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=17673"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/17673\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=17673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=17673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=17673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}