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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:02:38+00:00 2026-06-15T06:02:38+00:00

The beginning of my class is: class Player{ private: Cardpile hand; … } Where

  • 0

The beginning of my class is:

class Player{
private:
    Cardpile hand;
    ...
}

Where Cardpile is another class. If I do Player *p=new Player(); Is hand automatically initialized? I am asking this because I been trying to figure out a segmentation fault. I have looked everywhere in my code. The last thing I can think of is that hand is not initialized.

EDIT: This is the segmentation error I got. Card is a class inside of Cardpile. I know Card and Cardpile both works.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000402ac0 in __gnu_cxx::new_allocator<Card*>::construct (this=0x6070a8, __p=0x4015c6, __val=@0x7fffffffe6d8) at /usr/include/c++/4.4/ext/new_allocator.h:105
105           { ::new((void *)__p) _Tp(__val); }

EDIT: Cardpile class:

class Cardpile : private vector<Card*> {
    public:
    using vector<Card*>::size;
    using vector<Card*>::at;
    Cardpile ();
...
}
Cardpile::Cardpile(){}

EDIT: Here is a cool fact: p==NULL does not check if p is initiated. I guess that’s why I keep getting segmentation fault.

  • 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-15T06:02:40+00:00Added an answer on June 15, 2026 at 6:02 am

    If you don’t explicitly member initialize hand in your Player constructor, then the default constructor of Cardpile will be used.

    If you haven’t defined a default constructor, the compiler will create one.

    When you compile and link your program with -g, gdb can show the stacktrace where your program crashed:

    gdb program core
    

    and then inside gdb enter bt. This will show the complete call stack at time of the segmentation fault.

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

Sidebar

Related Questions

This is homework. Beginning Java class. Still wrapping my head around this stuff. The
This is from a beginning C++ class, no grade involved since I'm simply following
I was beginning to write a bubble sort for this when I thought maybe
This is the beginning of a script that displays thumbnails, worked fine, but I've
I'm implementing a custom video player because I need custom video controls. I have
Hi i am a beginner, and I have this homework for my beginning C
So I have the declaration at the beginning of my class file using System.Windows.Forms;
I'm writing a HandConverter of a poker hand. This is my first project and
team1name is initialized in the begining of the widget class String team1name= null; But
I'm taking a beginning Java class and an assignment requires that I write a

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.