Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8471221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:44:14+00:00 2026-06-10T16:44:14+00:00

So I am using default constructor to insert individual entries into memory and then

  • 0

So I am using default constructor to insert individual entries into memory and then read them by calling getBookInfo() method. When I try just to do a test run with only one variable I am not getting anything there even if I am calling getBookInfo() after I inserted the data.

Why is that?

Main.cpp

#include <iostream>
using namespace std;

#include "Book.h"

void main()
{
    Book book;

    book.setTitle("Advanced C++ Programming");
    book.setAuthorName("Linda", "Smith");
    book.setPublisher("Microsoft Press", "One Microsoft Way", "Redmond");
    book.setPrice(49.99);
    book.getBookInfo(); // <-= this should be output

    int i;
    cin >> i;
};

Book.cpp

#include <iostream>
#include <sstream>
using namespace std;

#include "Book.h"

Book::Book()
{
}

void Book::setTitle(string  title)
{
    title = title;
}


void Book::setPrice(double price)
{
    price = price;
}

string Book::convertDoubleToString(double number)
{
    return static_cast<ostringstream*>( &(ostringstream() << number) ) -> str();
}

// this should be output
string Book::getBookInfo()
{
    stringstream ss;
    ss << title << endl << convertDoubleToString(price) << endl;

    return ss.str();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T16:44:16+00:00Added an answer on June 10, 2026 at 4:44 pm

    You need to capture the data returned from getBootInfo(), for example

    string result = book.GetBookInfo();
    cout << result;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I create a std::string using the default constructor, is ANY memory allocated on
I'm not using the default Visual Studio project path to build my program into,
Are there any drawbacks / disadvantages using the default constructor for default initialization for
I'm using the default Date() constructor to get the current Date of the user.
I'm using Type.GetConstructor(Type.EmptyTypes) to get the default constructor for a class. It works if
I am using the default constructor and the default escape character which is backslash.
Java assigns default values to instance variables using default constructor. But if we define
I want to restrict creating object using default constructor. Because I have a desing
I have webserver using default virtualhost apache <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory
using the default route routes.MapRoute( Admin, // Route name Admin/{action}, // URL with parameters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.