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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:11:48+00:00 2026-06-09T07:11:48+00:00

class A { A a;//why can’t we do this in C++ but it is

  • 0
class A
{
    A a;//why can't we do this in C++ but it is allowed in Java?
};

Using this question, i came to know why it is not allowed in C++ but why is it allowed in java? According to same argument of not knowing the memory size while compilation, it should not be allowed in Java as well.

  • 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-09T07:11:49+00:00Added an answer on June 9, 2026 at 7:11 am

    In Java, if you have A a;, a is a reference to an object of class A. In C++, it’s not a reference, it’s a complete object.

    So the resulting object in C++ would be of infinite size, which isn’t very practical.

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

Sidebar

Related Questions

We know that TransactionScope class can use user-defined timeout value. But timeout exception is
I know AttributeUsage class. This class can set only property or method or class
In Rails. Exception can rescue in controller class but in model class can not.
I know that the Random class can generate pseudo-random numbers but is there a
What Swing class can I use to implement something like this? Add To List
In Java an anonymous inner class can refer to variables in it's local scope:
What class can we use to send a text message? I tried this on
A child class can access protected functions in parent class,but the parent class can't
Two parts to this: If a static class can have a static constructor, why
I know that the derived class can't access the private members of the base

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.