Solved

Distinction between struct and class - simple, but URGENT!!

Posted on 2003-10-22
2
310 Views
Last Modified: 2010-04-01
Dear experts,

I'm a newbie in C++ and am wondering what's the difference, in detail, between a struct and a class, with some examples so that I know whats going on!

Thanks!
0
Comment
Question by:nicholaf
2 Comments
 
LVL 4

Accepted Solution

by:
n_fortynine earned 500 total points
Comment Utility
structs originate from C, and classes are not. A basic difference between them is that for a struct the default state for its members is public, and for a class this state is private. For ex:
struct A {
   int a; //a is public by default
  private:
   int b;
};

class B {
   int a; //a is private by default.
  public:
   int b;
}

you can use them interchangebly if you keep this in mind.
0
 

Author Comment

by:nicholaf
Comment Utility
n_fortynine, thanks so much!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now