473,605 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is class is occupying any Memory??

1 New Member
hi,
I want to know is class is occupying any Memory??

suppose if i declare 10 different classes and don't create any instance of that classes, is that classes occupying any Memory??

class var
{
int a;
int b;
float c;
float d;
};

is the memory is allocated for this class???

regards,
fiem
Aug 14 '07 #1
1 1141
weaknessforcats
9,208 Recognized Expert Moderator Expert
No. Memory is not allocated when you declare a class. The class serves as information for the compiler os that when you create an object the compiler knows how big to make it. Then when you call methods on the object, the compiler can check to see of the methods are actualy part of the class. Only when you define an object is memory allocated:
Expand|Select|Wrap|Line Numbers
  1. //class declaration - no memory allocated
  2. class var
  3. {
  4. int a;
  5. int b;
  6. float c;
  7. float d;
  8. };
  9.  
  10. int main()
  11. {
  12.     var obj;          //object defined. Memory is allocated.
  13. }
  14.  
Aug 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

13
2361
by: Bryan Parkoff | last post by:
I have created three classes according to my own design. First class is called CMain. It is the Top Class. Second class and third class are called CMemory and CMPU. They are the sub-classes. Two sub-classes have the relationship to communicate back and forth through this pointer. The pointer is responsible inside Top class for allocating and deallocating two sub-classes. CMemory class is responsible to allocate and deallocate memory...
12
1879
by: James Brown | last post by:
Hi all, Having problems designing a template-class. I'll describe my scenario first then show what I've come up with so far: Need a class to provide pointer/array-like access to an area of physical memory located on a piece of custom hardware - this memory is only accessible using machine specific i/o so I want to hide all this in a class. I'm imagining
2
1287
by: James Brown | last post by:
Hi again, I'm referring back to my previous posting of the same title, with everyone's help I've now got a better understanding of what my goals are and I have a class which now looks like: template <typename type> class PhysMem { public:
1
2266
by: Marcos Boyington | last post by:
Hey guys, quick question about how C++ designers chose to not implement this, I'm sure there are some people here who can take a better guess at it than I. So, in C++, the only way to prevent typecasting to a base class is by having private inheritance (correct?). However, this prevents one from doing 2 very important things: Example #1: Allow conversion from child -> grandparent, but NOT child -> parent.
3
3497
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust ------------------------------------------------------------------------
2
1486
by: anand | last post by:
hi, i am fetching data from database using dataadaptor and filling up a dataset. i checked memory usage of the app, and it consumes 50 Mb of RAM for the given amount of data. that is, i checked the memory occupied by the app before and after fetching data. i saved the same amount of data in plain comma separated text file, which occupied 4Mb! i saved the same data in
3
2304
by: Stephen Torri | last post by:
Below is a class that is suppose to represent a segment of memory or a contents of a binary image (e.g. ELF executable). I have started to read Modern C++ Design and thought the best way to ensure I was understanding the chapter on policy classes was to attempt to apply them to my project. I understand the general concept of policies but I lack the knowledge and wisdom of how to identify them in an existing project. So I figured to get an...
6
4838
by: puzzlecracker | last post by:
I am kind of confused with the vpointer. Assuming the class has a virtual function. Would ONE pointer (occupying 16 bits) to virtual table be create for the class or One for each object? How does this pointer fit into aligment properties of an object (of the class) or class itself? Thanks
24
4196
by: GesterX | last post by:
First of all I'm new to this site but it certainly looks like a place that i will be visiting more often! Onto my problem. I am creating a Hotel Bussiness project in java using BlueJ The classes are as follows: Hotel - Deals with the major functions of the hotel (i.e guests booking in, finding rooms etc.) Room - Used to decide whether a room has a sea view and stores the guest that is in the room. Occupier - For information about the...
0
8001
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7934
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8415
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5445
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2438
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1270
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.