Why is the size of an empty class in C not zero

0 votes

Why does the following output 1?

#include <iostream>

class Test
{
};

int main()
{
    std::cout << sizeof(Test);
    return 0;
}
Aug 17, 2022 in C++ by Nicholas
• 7,760 points
337 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In C++

0 votes
0 answers

What is the meaning of "generic programming" in c++?

What does generic programming in C++ mean? I'm ...READ MORE

Jul 11, 2022 in C++ by Nicholas
• 7,760 points
379 views
0 votes
0 answers

What is the difference between cout, cerr, clog of iostream header in c++? When to use which one?

I looked up the differences between cout, ...READ MORE

Jul 27, 2022 in C++ by Nicholas
• 7,760 points
516 views
0 votes
1 answer

In C++, what is a virtual base class?

When employing multiple inheritance, virtual base classes are used to prevent several "instances" of a particular class from appearing in an inheritance hierarchy. Consider the following example: class A { public: void Foo() {} ...READ MORE

answered Jun 10, 2022 in C++ by Damon
• 4,960 points
368 views
0 votes
1 answer

What is the best way to use a HashMap in C++?

The ordered and unordered map containers (std::map and std::unordered map) are included in the standard library.  The items in an ordered map are sorted by key, and insert and access are in O (log n).  For ordered maps, the standard library often use red black trees.  However, this is only an implementation detail.  Insert and access are in O in an unordered map (1).  It is simply another term for a hashtable. An illustration using (ordered) std::map: #include <map> #include <iostream> #include <cassert> int main(int argc, char ...READ MORE

answered Jun 10, 2022 in C++ by Damon
• 4,960 points
500 views
0 votes
1 answer

What is a Class and Object in C++?

A Class is like a blueprint, an ...READ MORE

answered Jun 21, 2022 in C++ by Damon
• 4,960 points
306 views
0 votes
1 answer

In C++ abs( *a - *b) does not return absolute value of negative number

On the first line, you reallocated *a, and it is now utilising that new value on the second line.  int origa = *a; *a = abs(origa + ...READ MORE

answered Jun 27, 2022 in C++ by Damon
• 4,960 points
445 views
0 votes
1 answer

setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE

answered Sep 11, 2018 in Python by Priyaj
• 58,090 points
497 views
0 votes
1 answer

setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE

answered Sep 21, 2018 in Python by Priyaj
• 58,090 points
2,139 views
0 votes
1 answer

How to pass large records to map/reduce tasks?

Hadoop is not designed for records about ...READ MORE

answered Sep 25, 2018 in Big Data Hadoop by Frankie
• 9,830 points
1,215 views
0 votes
1 answer

Invalid method parameters for eth_sendTransaction

params needs to be an array, try {"jsonrpc":"2.0","method":"eth_se ...READ MORE

answered Sep 28, 2018 in Blockchain by digger
• 26,740 points
1,555 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP