Advertisement

03.02.2006 at 05:11AM PST, ID: 21757747
[x]
Attachment Details

how to create a simple class in C++

Asked by bryanlloydharris in C++ Programming Language

Tags: class, creating, simple

Can someone show me how to implement this same type of small idea in C++ with classes?

I made a tiny program in C, which makes a typedef of a two-digit number, like this:
struct two_digit_number {
      int one; // first digit
      int two; // second digit
};

Then I declare some numbers:
      // This means a = 05, because the 0 is in the second spot
      a.one = 5;
      a.two = 0;
      // This means b = 03
      b.one = 3;
      b.two = 0;

Then I have a function which adds them:
two_digit_number c = add_two_numbers(a, b);Start Free Trial
 
 
[+][-]03.02.2006 at 05:29AM PST, ID: 16084378

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.02.2006 at 05:30AM PST, ID: 16084383

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C++ Programming Language
Tags: class, creating, simple
Sign Up Now!
Solution Provided By: venkaiah
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03.02.2006 at 06:35AM PST, ID: 16084934

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.02.2006 at 06:51AM PST, ID: 16085075

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.02.2006 at 07:02AM PST, ID: 16085188

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.02.2006 at 07:04AM PST, ID: 16085205

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.02.2006 at 07:14AM PST, ID: 16085299

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32