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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:15:04+00:00 2026-06-12T14:15:04+00:00

Considering : double data; double array[10]; std::vector<int> vec(4, 100); MyClass myclass; Is there a

  • 0

Considering :

double data; 
double array[10]; 
std::vector<int> vec(4, 100); 
MyClass myclass;   

Is there a difference between :

sizeof(double);
sizeof(double[10]);
sizeof(std::vector<int>);
sizeof(MyClass);

and

sizeof(data);
sizeof(array);
sizeof(vec);
sizeof(myclass);

Are the two syntaxes different or strictly equivalent ? Are all of them evaluated at compile-time ? If not, which one is evaluated at run-time ?

  • 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-12T14:15:05+00:00Added an answer on June 12, 2026 at 2:15 pm

    The only differences are in syntax and convenience.

    Syntactically, you’re allowed to leave out the parentheses in one case, but not the other:

    double d;
    
    sizeof(double); // compiles
    sizeof(d);      // compiles
    sizeof d;       // compiles
    sizeof double;  // does NOT compile
    

    As far as convenience goes, consider something like:

    float a;
    
    x = sizeof(float);
    
    y = sizeof(a);
    

    If, for example, you sometime end up changing a from a float to a double, you’d also need to change sizeof(float) to sizeof(double) to match. If you use sizeof(a) throughout, when you change a from a float to a double, all your uses of sizeof will automatically change too, without any editing. The latter is more often a problem in C than C++, such as when calling malloc:

    float *a = malloc(10 * sizeof(float));
    

    vs.

    float *a = malloc(10 * sizeof(*a));
    

    In the first case, changing the first float to double will produce code that compiles, but has a buffer overrun. In the second case, changing the (only) float to double works fine.

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

Sidebar

Related Questions

Considering the basic data types like char, int, float, double etc..in any standard language
Considering this code with 3 differents function call semantics: void f(void){ puts(OK); } int
Considering that the two machine's time settings are not synced, is it still possible
I have read many questions considering thread-safe double checked locking (for singletons or lazy
Considering an int will be 4 bytes on a 32-bit system and 8 bytes
I'm considering creating an input/log file for my code for two main purposes. 1)
Considering the following function : template<typename... List> inline unsigned int myFunction(const List&... list) {
Considering the following example, the line int a = objT + 5; gives ambiguous
My, perhaps naive, solution for cloning an ArrayList (Vector replacement) is ArrayList<Double> alBis =
Considering the following TSQL: INSERT INTO Address(Street1, City, State, ZipCode) SELECT Street1, City, StateCode,

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.