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

  • Home
  • SEARCH
  • 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 9180383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:02:19+00:00 2026-06-17T18:02:19+00:00

Is int a class ? Please consider below code #includeiostream using namespace std; class

  • 0

Is int a class?

Please consider below code

#include"iostream"

using namespace std;

class test{
public:
    int a;

    test(int x)
    {
        cout<<"In test Constructor"<<endl;
        a = x;
    }
};

int main()
{
    test *obj = new test(10);// Constructor get called 
int *x = new int(10);    // Expecting the same if "int" is a class
return 0;
}
  • 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-17T18:02:20+00:00Added an answer on June 17, 2026 at 6:02 pm

    No, int is not a class, and int x = new int(10); is not valid C++ syntax.

    int* x = new int(5);
    ...
    ...
    delete x;
    

    This just creates a pointer to an int and new int(5) is a way to initialize a pointer.

    And the correct way should be delete[] x;

    No, because you allocated it with new, not new[]. The correct way though is int x = 5; or int x(5); – avoid dynamic allocation unless truly necessary.

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

Sidebar

Related Questions

Consider the sample program below: #include <iostream> using namespace std; class test { public:
please consider following code #include <iostream> using namespace std; class Digit { private: int
Please consider the following code : #include <iostream> using namespace std; class superclass; class
Consider the following code: #include <iostream> class Bar { public: void foo(bool b =
Please consider the following simplified example: #include boost/shared_ptr.hpp #include boost/smart_ptr/enable_shared_from_this.hpp using namespace boost; class
Consider following class class test { public: test(int x){ cout<< test \n; } };
Please consider the following simple use case: public class Foo { public virtual int
Consider this demo program: #include <stdio.h> class Base { public: virtual int f(int) =0;
Please consider the following code: class Abase{}; class A1:public Abase{}; class A2:public A1{}; //etc
Please pardon me for a n00bish question. Please consider the following code: public class

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.