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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:23:32+00:00 2026-06-12T17:23:32+00:00

I have a subclass of a class named Entity, and I wan’t that subclass

  • 0

I have a subclass of a class named Entity, and I wan’t that subclass to override Entity’s constructor, but calling Entity’s constructor too. So I declare the constructor like this:

EntitySphere(GLuint shader):Entity(shader){
    //Code
}

But that method only works if I implement the function there, in the class definition (or I get a lot of errors). How can I achieve the same, but being able to implement the constructor in the .cpp file?

  • 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-12T17:23:33+00:00Added an answer on June 12, 2026 at 5:23 pm

    To implement a constructor (or any method, for that matter) outside the class definition, you need to specify the name of the class before the method name:

    EntitySphere::EntitySphere(GLuint shader): Entity(shader) {
      // ...
    }
    

    Notice the EntitySphere:: part before the rest of the method.

    Otherwise, the compiler doesn’t know which method you’re providing the definition for. (Maybe it could be allowed to guess, but what if it guessed wrong and associated that implementation with some other function in your program?)

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

Sidebar

Related Questions

I have some Entities that look like this: @Entity public abstract class AbstractEntity{ @Id
I have a class named FirstViewController which is a subclass of UIViewController and I
Suppose I have a base class named Visitor, and it has 2 subclass Subscriber
I have created a subclass of UITableViewController that is used as the custom class
I have a ConfiguracaoDaApp class in my project that is a NSManagedObject subclass. I
I have set an onPreferenceClickListener on my subclass of DialogPreference like so: public class
I have a class hierarchy like this: @Entity @Table (name=call_distribution_policies) @Inheritance (strategy=InheritanceType.JOINED) public class
Using CoreData, I have an entity Bookmark, that has an to-many relationship named 'tags'
I have a subclass named child which inherits a class named parent. I am
Lets say I have a class named Dog which is a subclass of Animal

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.