As I noticed everybody says that THE ONLY difference between classes and structs is access mode.
But I have noticed that initialization is also different.
I mean if we have
struct SA{int n;};
class CA{public:int n;}
then we can write
SA sa = {2};
but we cannot write
CA ca = {2}; // compile error
Is not a difference also?
cigur
0
Newbie Poster
Recommended Answers
Jump to PostWhat compiler? Your statements work fine in VC++ 2008
Jump to PostYou can use a struct in practically (this means: in most cases, but not always) the same way as a class (because technically structs are classes in C++), consider the following example:
[B]struct[/B] s { void disp(); s(int num); [B]private:[/B] int n; }; s::s(int num) { n …
All 5 Replies
vmanes
1,165
Posting Virtuoso
Stinomus
11
Junior Poster
monkey_king
39
Junior Poster
ArkM
1,090
Postaholic
mvmalderen
2,072
Postaholic
NicAx64
commented:
thanks I'm digging you'r post
+1
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.