If struct keyword is support the all functionallity of class keyword,
only differance i have found is accessibility of member is different in
struct is public and class has private.
This accessbility feature user can got by using Accessor public,
private or protected.
So why class keyword is implemented in C++.
Thanks in advance. 12 1988
Viru Rathore wrote: If struct keyword is support the all functionallity of class keyword, only differance i have found is accessibility of member is different in struct is public and class has private. This accessbility feature user can got by using Accessor public, private or protected.
So why class keyword is implemented in C++.
Because it's cooler that way.
V
--
Please remove capital As from my address when replying by mail
Viru Rathore wrote: If struct keyword is support the all functionallity of class keyword, only differance i have found is accessibility of member is different in struct is public and class has private. This accessbility feature user can got by using Accessor public, private or protected.
So why class keyword is implemented in C++. Thanks in advance.
The point of OOD/OOP is information and process hiding by creating black
boxes with only the interfaces publicly available, (the need to know
basis for what is available). Hence for OOD/OOP development of an object
most of the data and methods would normally be private. But for backward
compatibility with old C code struct had to be supported with data and
methods defaulting to being public. Personally I always include explicit
declaration of scope, (private,protec ted or public), within an object.
JB
n2xssvv g02gfr12930 wrote: Viru Rathore wrote: If struct keyword is support the all functionallity of class keyword, only differance i have found is accessibility of member is different in struct is public and class has private. This accessbility feature user can got by using Accessor public, private or protected.
So why class keyword is implemented in C++. Thanks in advance.
The point of OOD/OOP is information and process hiding by creating black boxes with only the interfaces publicly available, (the need to know basis for what is available). Hence for OOD/OOP development of an object most of the data and methods would normally be private.
However, I find it much more logical to put the public members first, since
they are the part that is interesting for the largest group of people. So
my classes always start like:
class Foo
{
public:
It's similar with inheritance. The default is private, even though one
usually inherits publically way more often.
> However, I find it much more logical to put the public members first, since they are the part that is interesting for the largest group of people. So my classes always start like:
class Foo { public:
It's similar with inheritance. The default is private, even though one usually inherits publically way more often.
This is right but i want to know that we can do the same thing in
struct.
If we want private then we can define as private or required public we
define as public.
So why make a keyword different from struct to class.
OOD/OOP requird class keyword so make compitible to that OOAD grammer
to make this keyword.
Viru Rathore wrote: However, I find it much more logical to put the public members first, since they are the part that is interesting for the largest group of people. So my classes always start like:
class Foo { public:
It's similar with inheritance. The default is private, even though one usually inherits publically way more often.
This is right but i want to know that we can do the same thing in struct. If we want private then we can define as private or required public we define as public.
Yes. The two differences between the keywords struct and class are:
1. The default access / default inheritance
2. "class" can be used for a template parameter, "struct" can't.
So why make a keyword different from struct to class.
I guess it's just because the name "class" is so widespread for .... well, a
class.
OOD/OOP requird class keyword so make compitible to that OOAD grammer to make this keyword.
Something like that, yes.
"Rolf Magnus" writes: I guess it's just because the name "class" is so widespread for .... well, a class.
"class" was the word used in Simula 67, and perhaps before that. I checked
to see if Smalltalk preceded Simula 67 and chanced upon an interesting
article by Allan Kay. Which I will have to read some day when I have the
time. It's some of the early history of OOP. http://gagne.homedns.org/~tgagne/con...storyST.html#4
Viru Rathore ha scritto: If struct keyword is support the all functionallity of class keyword, only differance i have found is accessibility of member is different in struct is public and class has private. This accessbility feature user can got by using Accessor public, private or protected.
So why class keyword is implemented in C++. Thanks in advance.
I am not sure, but from what I understood (from strousdrup book) the
need of another keyword is
to avoid to modify C struct keyword and to mantain complete
consistence/compatibility with C.
ye
Pier Paolo
"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:67******** ************@co mcast.com... Viru Rathore wrote: If struct keyword is support the all functionallity of class keyword, only differance i have found is accessibility of member is different in struct is public and class has private. This accessbility feature user can got by using Accessor public, private or protected.
So why class keyword is implemented in C++.
Because it's cooler that way.
Classier, anyway.
-Howard
"Viru Rathore" <ra************ **@gmail.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.com...
If struct keyword is support the all functionallity of class keyword, only differance i have found is accessibility of member is different in struct is public and class has private. This accessbility feature user can got by using Accessor public, private or protected.
So why class keyword is implemented in C++.
Backwards compatibility, both with C and with older C++ code, I assume.
In my first C++ compiler (Turbo C++ 2, I think), the keyword struct meant a
purely C-style struct, what we call a POD ("plain old data") structure
today. No member functions, no inheritance, simply public data. The class
keyword in that software indicated the new C++-style definition, with member
functions and inheritance allowed.
I (and many other programmers, I'm sure) still tend to program in that
fashion, using struct only for pure POD data holders, and class for
everything else.
-Howard This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Shao Zhang |
last post by:
Hi,
I am not sure if the virtual keyword for the derived classes are
required given
that the base class already declares it virtual.
class A
{
public:
virtual ~A();
|
by: Jason Heyes |
last post by:
I want to write a class that supports operations on keywords belonging to
the C++ programming language. The following program repeatedly prompts the
user for a keyword until 'explicit' is finally entered:
#include <iostream>
#include "KeyWord.h"
int main()
{
KeyWord word;
|
by: modemer |
last post by:
Question is as in subject.
For example:
class BaseClass {
public:
void func() { do something; } // I don't want this function being
overloaded in its inherited class
};
|
by: kuvpatel |
last post by:
Hi
I want to refer a class called LogEvent, and use one of its methods called
WriteMessage without actually having to create an instance of Logevent.
I have tried using the word sealed with the class and this works but I would
also like to know of other ways to do this.
Also are there any performance implacations of using sealed?
|
by: Brian Henry |
last post by:
If i inherite a queue class into my class, and do an override of the enqueue
member, how would i then go about actually doing an enqueue of an item? I am
a little confused on this one... does over ride just add aditional code
ontop of the current class or completely over ride it in vb? I am use to C++
this is the first inherited thing I've done in VB.NET... I'm a little unsure
of diffrences, could someone explain this to me some? thanks!
| |
by: Dylan Moreland |
last post by:
I'm trying to implement a bunch of class methods in an ORM object in
order to provide functionality similar to Rails' ActiveRecord. This
means that if I have an SQL table mapped to the class "Person" with
columns name, city, and email, I can have class methods such as:
Person.find_by_name
Person.find_by_city_and_name
Person.find_by_name_and_city_and_email
I have a metaclass generating basic properties such as .name and .city,
|
by: key9 |
last post by:
Hi All
I 've got no idea how to describe it on subject.
See code:
//ABC
class Keyword{}; // user's command
class Handler{}; // command's action
// A Command contain A Keyword* + A Handler*
|
by: Miro |
last post by:
Vb2003, im still learning vb.net but I do not understand my output from this
logic.
If someone can help me out here.
Cor Ligthert, you I believe were on the right track of what Im trying to
create.
-Thank you very much for leading me on to Classes.
Ok here is my code. ( see below )
|
by: Hongyu |
last post by:
Hi,
I am a newbie in C++. I saw a code like the below and don't understand
it.
class A
{
public:
A();
|
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...
|
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,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |