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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:07:23+00:00 2026-06-18T00:07:23+00:00

I am currently learning OOP for a project I’m working on (I’m in highschool

  • 0

I am currently learning OOP for a project I’m working on (I’m in highschool and have some experience with c++; this is my third ‘large’ (>3 months) c++ project.) I have the basics of C++ classes figured out and managed to make some of the classes for the project.

So these is my page.h header:

class cl_Page{
public:
  cl_Page(cl_LessonMoment *parent_param);
  cl_Page(cl_SoftRoot *parent_param);
  int parent_type;
  cl_LessonMoment *parent_lmoment;
  cl_SoftRoot *parent_softroot;

  char id[256];

  //<content>
  //Backgrounds.
  str_Color bgcolor;
  cl_Image bgimage;

  //Actual content
  vector<cl_Textbox> textboxes;
  vector<cl_Button> buttons;
  vector<cl_Image> images;
  //</content>
};

(include guards and such are not here, but they are in my project)

And this is my page.cpp:

cl_Page::cl_Page(cl_LessonMoment *parent_param){
  parent_lmoment = parent_param;
  parent_type = 1;
  id[0] = '\0';
  //bgimage(NULL);
  SetColor(bgcolor, 0x000000ff);
}

(the other constructor is similar, it just sets a different type of parent)

My problem is that I want to call the constructor to bgimage (which is of cl_Image class type) inside my cl_Page constructor. If I try this (uncomment the line in the constructor), obviously it won’t work.

So yeah, how do I call the constructor now? I really need to construct every member along with the cl_Page object.

  • 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-18T00:07:24+00:00Added an answer on June 18, 2026 at 12:07 am

    If you want to create bgImage object in cl_Page constructor, it has to be either a pointer (1) or you should use a constructor’s initialization list (2), which in this case would probably be a better solution for you.

    1. – Field is a pointer to cl_Image

    bgImage = new cl_Image(nullptr);
    

    2. – Use of constructor’s initialization list

    cl_Page::cl_Page(cl_LessonMoment *parent_param) :
          bgImage(nullptr) 
    {
      parent_lmoment = parent_param;
      parent_type = 1;
      id[0] = '\0';
      SetColor(bgcolor, 0x000000ff);
    }
    

    There you can read more about constructor’s initialization list: http://www.cprogramming.com/tutorial/initialization-lists-c++.html

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

Sidebar

Related Questions

im currently learning python (in the very begining), so I still have some doubts
Currently learning Scheme/Racket and have problem running this piece of code. (if (or (<
I'm currently learning Django and some of my models have custom methods to get
I'm currently learning assembler and writing some program in real mode. I have some
Currently Learning Web project in Java. I have a doubt related to it. Actually
im currently learning stacks in java and have a quick question. what will the
I am currently learning C, and am having some issues with trying to make
I'm currently learning C for my next emulation project, a cycle accurate 68000 core
I'm currently learning about cube mapping, I found this tutorial: http://www.keithlantz.net/2011/10/lighting-and-environment-mapping-with-glsl/ He transform normal
Im new in OOP programming and C++ and Im currently into learning design patterns.

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.