#include<iostream>
using namespace std;
class A
{
int a[];
};
int main()
{
cout<<sizeof(A);
return 0;
}
Antriksh_1
0
Newbie Poster
Recommended Answers
Jump to Postclass A { int a[]; // zero sized array };
You should receive a warning when compiling this due to
int a[]
being a zero sized array.
Jump to PostWhen I compile this I get
warning: ISO C++ forbids zero-size array 'a'
although I am using the 2003 standard.You have declared a zero size array in the class therefore the class has no data and is zero-sized. Since the array has members it appears that the compiler (mine …
All 6 Replies
nullptr
167
Occasional Poster
Banfa
597
Posting Pro
Featured Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
mike_2000_17
2,669
21st Century Viking
Team Colleague
Featured Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
mike_2000_17
2,669
21st Century Viking
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.