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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:42:56+00:00 2026-05-30T11:42:56+00:00

I am mostly a Java and AS3 programmer but right now I am working

  • 0

I am mostly a Java and AS3 programmer but right now I am working in C++ for something and I stumbled upon a problem.
I have a base class (let’s call it ClassA) that has a private variable var1. In this class I have a method getVar1() that returns a pointer to that variable.

Next I have another class that extends Base (let’s call it ClassB). How do I call the getVar1() from the super class?
In java it is as simple as this.var1 = super.getVar1().

I read that it is like var1 = ClassA::getVar1(), but I am not sure if this is OK for work with variables (aka the pointers can change).

Thanks.

  • 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-30T11:42:57+00:00Added an answer on May 30, 2026 at 11:42 am

    it’s ok to call it ClassA::getVar1().

    However, if you want the java-way, you can make the method “virtual”. This means whenever you write getVar1(), it doesn’t depend on the Type you wrote in front of it (so at compile time) but it depends on the type of the object when you call it (at runtime). For this reason, c++ keeps an internal v-table to find the appropriate method. It’s equivalent to the java way and called late-binding.

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

Sidebar

Related Questions

I have been programming in Java since 2004, mostly enterprise and web applications. But
I do mostly Java and C/C++ development, but I'm starting to do more web
I'm mostly a .Net person at the moment, but I've been playing with Java
I have some enterprise apps running on Java 1.4. They mostly invoke Stored Procedures
I have a web application written mostly in Java. There are a few users
I mostly write in C but am using Java for this project. I want
My application is mostly Java but, for certain calculations, uses a C++ library. Our
I have a Java program that is mostly GUI and it shows data that
I'm working especially with Java web applications (in which mostly with JSF, Java Server
I have a project which will be made up mostly of Java Servlets, JSP/Html

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.