FACTOID # 146: About one-quarter of all nations drive on the left-hand-side of the road. Most of them are former British colonies.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > C plus plus struct

A C++ struct is actually an extension of the C language struct in that the ability to specify methods is added. In fact, the only difference between a struct and a class in C++ is that by default the latter's members and base classes are private, whereas in a struct, by default the members and bases are public. An example of a declaration for a C++ struct is:

 struct SomeStruct { SomeStruct(); virtual ~SomeStruct(); void someMethod(); }; 

SomeStruct() and ~SomeStruct() are the constructor and destructor, respectively, and someMethod() is a method of the struct. All members are public since no visibility is specified.


One could create an instance of this struct by declaring it like so on the stack:

 SomeStruct thisStruct; 

You could then access the methods of thisStruct like so:

 thisStruct.someMethod(); 

  Results from FactBites:
 
C plus plus:Modern C plus plus:Appendices:Casts - GPWiki (1163 words)
C++ introduced const, which is a very powerful tool for avoiding programmer logic and design errors.
Using C++ casts will make it clearer what your intention is for a cast and force you to think about and understand why the types don't match, which are both good things.
In fact, C-style cast is defined by the C++ Standard simply as the first cast to succeed in an increasingly-unsafe sequence of C++ casts.
C++ - Wikipedia, the free encyclopedia (3736 words)
C++ supports this (via member functions and friend functions), but does not enforce it: the programmer can declare parts or all of the representation of a type to be public, and is also allowed to make public entities that are not part of the representation of the type.
This is partly because the C++ grammar is not LALR(1).
C++ is sometimes compared unfavorably with single-paradigm object-oriented languages such as Java, on the basis that it allows programmers to "mix and match" object-oriented and procedural programming, rather than strictly enforcing a single paradigm.
  More results at FactBites »


 
 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms, 1022, m