C++
How much m ...
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
How much memory does an empty class object take?
0 byte
1 byte
4 bytes
Depends on the platform.
Explanation
According to the standard, the size of the object cannot be equal to 0, so the size of the object is equal to the size of 1 char symbol.
class
memory
memory allocation
Like
Login in
to like
Comment
Login in
to comment
Share
Tweet
Related Content
Какой из двух классов занимает больше памяти в C++: class A{ int i; int foo(int a); }; Class B{ int i; virtual int boom(int b); };
Чему равен sizeof(A) на 32-х разрядной платформе, где A имеет следующее описание: class A { int a; char ch; double d; virtual void f() = 0; };
Сколько памяти занимает объект пустого класса?
#include <iostream> using namespace std; int &test() { static int a = 3; return a; } int main() { ++++++test(); cout << test() << endl; return 0; } Что выведет cout?
что будет выведено на экран: #include <memory> #include <iostream> class SomeObj { public: SomeObj() : val_(std::make_shared<int>(10)) {} SomeObj(const int& val) : val_(std::make_shared<int>(val)) {} const int& operator*() const { return *val_; } int& operator*() { return *val_; } private: std::shared_ptr<int> val_; }; SomeObj getSomeObj(const int& i) { return SomeObj(i); } int main() { const int& v = *getSomeObj(100); std::cout << v; return 0; }
C
++
Quiz
Login to learn C++
or
Read more about
C++ Quizzes
Follow CodeGalaxy
Mobile Beta
Send Feedback
Keep exploring
C++ quizzes
int main() { const int* i = int(); // 1 int const* j = int(); //2 int* const k = int(); //3 int* l(); //4 ++i; //5 ++j; //6 ++k; //7 ++*k; //8 ++l; //9 } Откомпилируется ли такой код? Если нет, то в каких строчках будут ошибки компиляции? После стандарта C++14.
Какой результат работы программы? #include <iostream> using namespace std; void f(double) { cout<<"f1"<<endl; } void f(const int ) { cout<<"f2"<<endl; } void f( int & ) { cout<<"f3"<<endl; } void main(void) { int n = 1; double b = 2; f(n); f(b); }
При истинности какого из приведенных высказываний имеет смысл вычитание указателей?
Какое ключевое слово используется для описания пространства имен?
В чем разница между X x; и X x(); ?
Скомпилируется ли этот код: struct A : int { };
Sign Up Now
or
Subscribe for future quizzes
Login in to like
Login in to comment