473,472 Members | 2,224 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

struct vs. class usage

What is the difference between a struct and a class ?

When should a struct be used and when should a class be used ?

Dec 29 '06 #1
6 2867

subramanian wrote:
What is the difference between a struct and a class ?

When should a struct be used and when should a class be used ?
The only difference is the name itself and the default access.
Some will suggest using struct for PODs (Palin Old Data).
Otherwise they are exactly the same.

Dec 29 '06 #2

subramanian wrote:
What is the difference between a struct and a class ?

When should a struct be used and when should a class be used ?
FWIW this and many other things are covered in the associated faq:

http://www.parashift.com/c++-faq-lite/

regards
Andy Little

Dec 29 '06 #3
subramanian wrote:
What is the difference between a struct and a class ?

When should a struct be used and when should a class be used ?
This is a FAQ.

http://www.parashift.com/c++-faq-lit...s.html#faq-7.8
Dec 29 '06 #4

subramanian wrote:
What is the difference between a struct and a class ?

When should a struct be used and when should a class be used ?
as already few friends told access difference in struct and class but i
suggests you to write code related to struct in .c file and related to
class in .cpp file, after that one by one apply all concept of Object
Oriented Concept on both files then you will find crystal difference
between struct and class.

i hope it will helps you.

regards,

-aims

Dec 29 '06 #5
Bingo asim!
Rest all differences mentioned are meant between "c++" struct and
class. But mind you, c and c++ structures are a lot different (see to
it like struct in c is given all OO power of class in c++)

Sandip Shahane

Mohammad Omer Nasir wrote:
subramanian wrote:
What is the difference between a struct and a class ?

When should a struct be used and when should a class be used ?

as already few friends told access difference in struct and class but i
suggests you to write code related to struct in .c file and related to
class in .cpp file, after that one by one apply all concept of Object
Oriented Concept on both files then you will find crystal difference
between struct and class.

i hope it will helps you.

regards,

-aims
Dec 29 '06 #6

Sandip Shahane wrote:
Bingo asim!
Rest all differences mentioned are meant between "c++" struct and
class. But mind you, c and c++ structures are a lot different (see to
it like struct in c is given all OO power of class in c++)

Sandip Shahane
Please don't top Post.
>
Mohammad Omer Nasir wrote:
subramanian wrote:
What is the difference between a struct and a class ?
>
When should a struct be used and when should a class be used ?
as already few friends told access difference in struct and class but i
suggests you to write code related to struct in .c file and related to
class in .cpp file, after that one by one apply all concept of Object
Oriented Concept on both files then you will find crystal difference
between struct and class.

i hope it will helps you.

regards,

-aims
Dec 29 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Kilana | last post by:
I see this all the time in code: typedef struct a_struct { ... }differentName, *differentNamePtr; I understand how I can use it, but could someone tell me why the above is
4
by: Steve | last post by:
I'll be the first to admit, I'm not entirely clear on the appropriate usage of either. From what I am reading in my books, a Struct and a Class are pretty much the same, with the difference being,...
11
by: Daniele Benegiamo | last post by:
Is the following program standard-compliant? I've compiled it with some compilers and no errors or warnings are produced, but this is not a demonstration. The "incriminated" part is the...
22
by: Ook | last post by:
We have had a discussion on the differences between a class and a structure, and no one is in agreement. As I understand it, a structure defaults to public, a class defaults to private. There are...
2
by: Peter Steiner | last post by:
hi there! my problem: i need arrays of float-triples (math vector). i need these available in a flat float* array for batch processing (opengl). is an array of POD structs with three float...
5
by: Chris | last post by:
Hi, I don't get the difference between a struct and a class ! ok, I know that a struct is a value type, the other a reference type, I understand the technical differences between both, but...
1
by: jheled | last post by:
Staring with g++ 3.4, this code results in an error ---------------------------------- struct A { }; class B : private A { };
21
by: Zytan | last post by:
Is it possible, as in C? I don't think it is. Just checking. Zytan
4
by: Ed | last post by:
Hi, guys, In C language manner, we need to put a "struct" token before one struct variable declaration like following. <code> struct Apple { float Price; };
0
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...
0
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.