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 3681048
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:38:55+00:00 2026-05-19T03:38:55+00:00

I am reading Bjarne Stroustrup’s Programming : Principles and Practice Using C++ In the

  • 0

I am reading Bjarne Stroustrup’s Programming : Principles and Practice Using C++

In the drill section for Chapter 2 it talks about various ways to look at typing errors when compiling the hello_world program

#include "std_lib_facilities.h"

int main()  //C++ programs start by executing the function main
{
    cout << "Hello, World!\n",  // output "Hello, World!"
    keep_window_open();         // wait for a character to be entered
    return 0;
}

In particular this section asks:

Think of at least five more errors you
might have made typing in your
program (e.g. forget
keep_window_open(), leave the Caps
Lock key on while typing a word, or
type a comma instead of a semicolon)
and try each to see what happens when
you try to compile and run those
versions.

For the cout line, you can see that there is a comma instead of a semicolon.
This compiles and runs (for me). Is it making an assumption ( like in the javascript question: Why use semicolon? ) that the statement has been terminated ?

Because when I try for keep_terminal_open(); the compiler informs me of the semicolon exclusion.

  • 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-05-19T03:38:55+00:00Added an answer on May 19, 2026 at 3:38 am

    The comma operator in C++ can be used as follows:

    a, b;
    

    It means “do a, disregard the result, then do b.” You can chain it together like this:

    a, b, c, (etc.), n;
    

    In general, this isn’t considered good style. The comma operator is rarely used in practice because it’s confusing. The few times it’s legitimately useful usually come up with for loops:

    for (int a = 0, b = 0; a < 100; a++, b++) {
        /* ... */
    }
    

    Here, we use the comma operator in the last part of the for loop to mean “increment both a and b.”

    To answer your question, yes, you should have a semicolon after the cout. Using the comma operator technically works as well, but it’s inelegant and likely to confuse people.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading MSDN (and other sources) about custom report items (CRI) for reporting services 2005.
Bjarne Stroustrup writes in his C++ Style and Technique FAQ , emphasis mine: Because
I am currently reading Stroustrup's book "Design and Evolution of C++" and it turns
Reading section 9.1 of OAuth Core 1.0, I only see a reference to performing
Reading conflicting opinions on using SQL session state vs custom db table in MVC
Reading various properties of the Outlook.MAPIFolder.Items collection results in an error when the user
Reading around, the svn:ignore command seems to work one of two ways: If the
Reading Guru-Gu's blog post about ASP.NET MVC3 hitting RC , he says:- Session-less Controller
Reading this question I found this as (note the quotation marks) code to solve
Reading an article called Increase LINQ Query Performance in July's MSDN magazine, the author

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.