Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Feb 4th, 2007, 12:23 PM   #1
sharadpro
Newbie
 
Join Date: Feb 2006
Location: India
Posts: 25
Rep Power: 0 sharadpro is on a distinguished road
Size of inherited class!

#include<iostream>
using namespace std;

class X
{
int x;
public:
int y;
protected:
int z;
};

class Y : public X
{
int a;
public:
int b;
protected:
int c;
};

int main()
{
cout<<sizeof(Y);
return 0;
}


According the output (24 on my machine) , even the variable x which was private in class X is being considered as a part of class Y?
Please explain!
sharadpro is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
singly-linked list templaste class in C++ w/ example driver bl00dninja Show Off Your Open Source Projects 0 Sep 11th, 2006 2:05 AM
Wierd compile Error. Need help please. Keiyentai Java 7 Aug 19th, 2006 2:35 AM
What is: "Oriented programming (OO)?" BrinyCode C++ 12 Nov 22nd, 2005 8:40 AM
User Input for Number Format ericelysia1 Java 0 Jul 21st, 2005 4:41 PM
MFC/OpenGL: problem with 'Document' class brenda C++ 11 May 23rd, 2005 9:10 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:49 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC