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

  • Home
  • SEARCH
  • 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 8874273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:40:39+00:00 2026-06-14T18:40:39+00:00

I tried to init a stringstream reference member with nothing, saying I wanted it

  • 0

I tried to init a stringstream reference member with nothing, saying I wanted it to refer to null or just leave it un-initialized.

.hpp file

class Class{
    private:
        int n;
        stringstream& css;
    public:
        Class(int n);
        Class(stringstream& ss, int i);
    };

.cpp file

Class::Class(int n)
    :   n(n)    
{}

The compiler gives:
Error 1 error C2758: ‘Class::css’ : must be initialized in constructor base/member initializer list

Do I have to initialize all the variables in the initialization list?
Because I am not passing any stringstream reference to the constructor, how do I initialize it? Or if I don’t want to initialize it, leave it blank. How do I do so?

  • 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-14T18:40:40+00:00Added an answer on June 14, 2026 at 6:40 pm

    References members must be initialized. You don’t want a reference, you want a pointer.

    class Class{
    private:
        int n;
        stringstream* css;
    public:
        Class(int n);
        Class(stringstream& ss, int i);
    };
    
    Class::Class(int n)
        :n(n), css(nullptr)    
    {}
    
    Class::Class(stringstream& ss, int i)
        :n(i), css(&ss)
    {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for the init .py file for django. I tried whereis and
I've tried two ways to declare a member function in JS: function init() {
I create a QRadioButton array and tried to init it with six radioButtons. At
I've tried both of the following: repo init -u git://android.git.kernel.org/platform/manifest.git -b android-2.1 repo init
I would like to init my ORB from property file (normally I init it
I tried this: NSDateFormatter *df= [[[NSDateFormatter alloc] init] autorelease]; [df setDateFormat:@yyyy-MM-dd HH:MM:SS]; NSDate *dt2
I tried below code : NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSString *
I tried to return a value in a class constructor ( init ): class
I tried to run gcov with -fprofile-arcs & -ftest-coverage and nothing for linking. It
I just tried to omit the SDL_Init() function, but everything is still working. By

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.